Next: , Previous: , Up: Tutorial   [Contents][Index]


2.2 Generating Documentation from Typelibs

Loading typelibs alone might be all you need if you have perfect knowledge of all the libraries you are going to use and an intuitive understanding of how they are mapped to Scheme procedures. Chances are, however, that you do not. In this case, it might be useful to generate some documentation. See Typelib Documentation.

Upon installation of Guile-GI, we install a script called gi-gtkdoc, that can be invoked through guild. Running the script will create HTML documentation for a typelib file.

You may also want to create a guile-procedures.txt file for use in the REPL. We currently have no script for that, but one can easily be written. The following for example exports all the documentation for GObject-2.0.

#!/path/to/guile
!#
(use-modules (gi documentation))

(let ((%typelib (typelib "GObject" "2.0"))
      (%gir (false-if-exception (gir "GObject" "2.0")))
      (%doc '()))
  (set! %doc (parse %typelib %doc))
  (close %typelib)
  (when %gir
    (set! %doc (parse %gir %doc))
    (close %gir))
  (->guile-procedures.txt %doc))

Use shell pipes to redirect the output into a file, preferably one called “guile-procedures.txt”. Guile will search for documentation in such files in a few locations, including the current working directory.