On Monday, February 11, 2013 at 4:16:05 AM UTC+1, Zbigniew Jędrzejewski-Szmek wrote: > > Hi, > I'm trying to document a C extension module containing a number of > constants. I'd like both their names and values to appear in the > sphinx HTML output. I'm using sphinx.autodoc extension, but it ignores > the constants. > > The constants are defined as instances of uuid.UUID. > I have: > .. automodule:: systemd.id128 > :members: > :undoc-members: > > This shows everything I want except the constants. >
I'm in the same boat here. I saw that you went with the autoattribute approach, thus duplicating your code file in the documentation. It should be possible to avoid that by using the Python 'ast' module from within a Sphinx extension to emit something like: .. attribute:: mymodule.MYCONSTANT :annotation: = somevalue ...for each sympol found via the ast module, thus avoiding the duplication. The ast module is quite simple to work with so it wouldn't add much code, and be resilient to change. There is one problem though, I have no idea what extension code is needed to create the above from say, for example: .. myautoconst:: mymodule ...and I'm having a hard time to make sense of the documentation. The goal here should be, for me at least, to have the attributes cross-referable via `MYCONSTANT` and the default_role='any'. Any help would be very much appreciated. Either to get this working, or to fix sphinx to actually automatically document the consts. -- You received this message because you are subscribed to the Google Groups "sphinx-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sphinx-users. For more options, visit https://groups.google.com/d/optout.
