Commits

Anonymous committed 3e8a548

sdlttf.get_sys_font() returns None on failure now. Added data field support to rst documentation.

Comments (0)

Files changed (8)

 Test releases:
 
 * alpha1 (rev. 2176)
+* alpha2 (rev. )
     lib/__init__.py
     
 * Update NEWS.txt with the changes since the last version (only for final
-  release - alpha and rc should contain the information, but not be tagged
+  releases - alpha and rc should contain the information, but not be tagged
   explicitly). See :ref:`Editing News` for more information.
 
 * Update README.txt and doc/BuildXXX.txt to point to the latest required

doc/create_rstref.py

         self.description = "TODO"
         self.example = ""
         self.classes = []
+        self.data = {}
         self.functions = []
         self.includes = []
     
         module = self.get_module_docs (dom)
         self.get_module_funcs (module)
         self.get_class_refs (module)
+        self.get_data (module)
         self.get_includes (module)
 
+    def get_data (self, module):
+        data = module.getElementsByTagName ("data")
+        for entry in data:
+            name = entry.getAttribute ("name")
+            val = entry.firstChild.nodeValue.strip ()
+            self.data[name] = val
+
     def get_includes (self, module):
         incs = module.getElementsByTagName ("include")
         for node in incs:
         if len (self.example) > 0:
             fp.write (self.create_example_rst (self.example, True))
 
+        if len (self.data) > 0:
+            fp.write ("Data Fields\n")
+            fp.write ("-----------\n")
+            for key in self.data.keys ():
+                fp.write (".. data:: %s\n" % key)
+                fp.write (self.create_desc_rst (self.data[key], 2))
+
         if len (self.functions) > 0:
             fp.write ("Module Functions\n")
             fp.write ("----------------\n")
 <!DOCTYPE module [
 <!ELEMENT module
-          (show?, alias?, short, desc, example?, (func | class)*, include*)>
+          (show?, alias?, short, desc, example?,
+          (data | func | class)*, include*)
+          >
 <!ATTLIST module name CDATA #REQUIRED>
 
 <!ELEMENT show (0 | 1) "1">
 <!ELEMENT desc (#PCDATA)>
 <!ELEMENT short (#PCDATA)>
 
+<!ELEMENT data (#PCDATA)>
+<!ATTLIST data name CDATA #REQUIRED>
+
 <!ELEMENT call (#PCDATA)>
 <!ELEMENT include (#PCDATA)>
 
     the whole pygame2 package.
   </desc>
 
+  <data name="__version__">
+    The version of the Pygame2 package as string.
+  </data>
+
+  <data name="version_info">
+    The version of the Pygame2 package as value tuple. The tuple is of
+    the form ``('major', 'minor', 'micro', 'releaselevel')``, where all
+    values except the *releaselevel* are integers.
+  </data>
+
   <class name="BufferProxy">
     <constructor>BufferProxy () -> BufferProxy</constructor>
     <desc>Creates a new, empty :class:`BufferProxy`.
       A class for storing rectangular coordinates.
 
       A :class:`FRect` is used to store and manipulate rectangular coordinates.
-      TODO
     </desc>
     <attr name="bottom">
       <desc>Gets or sets the bottom edge position of the :class:`FRect`.</desc>
     <desc>A class for storing rectangular coordinates.
 
     A :class:`Rect` is used to store and manipulate rectangular
-    coordinates.  TODO
+    coordinates.
     </desc>
     <attr name="bottom">
       <desc>Gets or sets the bottom edge position of the :class:`Rect`.</desc>

lib/sdlttf/sysfont.py

 
 def get_sys_font (name, size, style=constants.STYLE_NORMAL):
     """
-    pygame2.sdlttf.get_sys_font (name, size, style=constants.STYLE_NORMAL) -> Font
+    get_sys_font (name, size, style=constants.STYLE_NORMAL) -> Font
     
     Create a Font from system font resources
 
     enable bold or italic styles, and the appropriate system font will be
     selected if available.
 
-    This will always return a valid Font object, and will fallback on the
-    builtin pygame font if the given font is not found.
-
     Name can also be a comma separated list of names, in which case set of
     names will be searched in order.
     """
         fontname, gotbold, gotitalic = \
             pygame2.font.find_font (name, bold, italic)
     if not fontname:
-        # TODO: default font!
-        pass
-
+        return None
+        
     font = Font (fontname, size)
 
     setstyle = constants.STYLE_NORMAL
     Uint32 flags;
     if (!PyArg_ParseTuple (args, "l:quit_subsystem", &flags))
         return NULL;
-    /* TODO: SDL related modules does not quit correctly, etc. as the
+    /* TODO: SDL related modules do not quit correctly, etc. as the
      * _quit() hooks are not called! */
     SDL_QuitSubSystem (flags);
     Py_RETURN_NONE;

src/sdlttf/font.c

     0,                          /* tp_traverse */
     0,                          /* tp_clear */
     0,                          /* tp_richcompare */
-
-    /* 
-     * tp_weaklistoffset
-     * FIXME: Weakrefs? Do we need those? 
-     */
-/*    offsetof(PySDLFont_TTF, weakrefs) */
-    0, 
-
+    0,                          /* tp_weaklistoffset */
     0,                          /* tp_iter */
     0,                          /* tp_iternext */
     _font_methods,              /* tp_methods */
     0,                          /* tp_dict */
     0,                          /* tp_descr_get */
     0,                          /* tp_descr_set */
-
-    /* 
-     * tp_dictoffset
-     * FIXME: What about the dictionary? Hueuh...
-     */
-/*    offsetof(PySDLFont_TTF, dict) */
-    0, 
-
+    0,                          /* tp_dictoffset */
     (initproc) _font_init,      /* tp_init */
     0,                          /* tp_alloc */
     _font_new,                  /* tp_new */
 
     font->pyfont.get_height = _font_getheight;
 
-    // TODO: Which get name? We've got family name and style name.
-    font->pyfont.get_name = NULL;
+    font->pyfont.get_name = _font_getfamilyname;
     font->pyfont.get_style = _font_getstyle;
     font->pyfont.set_style = _font_setstyle;
     font->pyfont.get_size = _font_getsize;
     font->pyfont.render = _font_render;
-    font->pyfont.copy = NULL; // TODO
+    font->pyfont.copy = NULL; /* TODO */
 
     return (PyObject*) font;
 }