Expose open data about documented modules

22 views
Skip to first unread message

anatoly techtonik

unread,
Jul 23, 2015, 2:32:09 AM7/23/15
to sphinx-dev
There are 17 votes and 2500+ views over 4 years about how to get the list of modules in Python stdlib:

One of the approaches recommended parsing Sphinx objects.inv file, which is rather hard to do from a web
application that could provide some stats about those modules (like fetch amount of bugs for those from
elsewhere).

So, I am thinking how hard is it for Sphinx to generate a list of modules by the following URL?
https://docs.python.org/3/_data/1.0/modules.json

  _data - directory named like a _static, but for data. It can be made dynamic if needed.
  1.0  - versioning required for changes in data format, so that former web apps continue to work

Is it a good think to make it a common Sphinx feature?

Robert Lehmann

unread,
Jul 25, 2015, 6:49:01 AM7/25/15
to sphin...@googlegroups.com
If any such functionality was added, I'd intertwine it with the serializing builders.

From the StackOverflow link you gave I'm not convinced it's a common request for Sphinx but we happily accept pull requests.

Cheers,
Robert


--
You received this message because you are subscribed to the Google Groups "sphinx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

anatoly techtonik

unread,
Jul 26, 2015, 2:08:56 AM7/26/15
to sphin...@googlegroups.com
What is the difference between ordinary builder and serializing builders?

Also, won't it be easier to just make an event handler for doctree-resolved
instead of full fledged builder?

Also, how can I get all module names from doctree object?

Takayuki Shimizukawa

unread,
Jul 26, 2015, 2:40:58 AM7/26/15
to sphin...@googlegroups.com
IMO, independent sphinx extension is good place to start implementing new feature.
Almost features can be implemented as a sphinx extension.

BTW, all module data is stored in `Environment.domaindata`.
Please check ``sphinx/domains/std.py`` as a usage sample.

Regards.
--
Takayuki SHIMIZUKAWA

2015年7月26日(日) 8:08 anatoly techtonik <tech...@gmail.com>:
--

anatoly techtonik

unread,
Jul 26, 2015, 4:42:42 PM7/26/15
to sphinx-dev, shimi...@gmail.com
On Sunday, July 26, 2015 at 9:40:58 AM UTC+3, Takayuki SHIMIZUKAWA wrote:
IMO, independent sphinx extension is good place to start implementing new feature.
Almost features can be implemented as a sphinx extension.

How to get the list of all module names? I am trying to traverse
nodes of doctree, but there is no module name there. The code:

    def writedata(app, doctree, docname):
        for node in doctree.traverse():
            print node.tagname

    def setup(app):
        app.connect("doctree-resolved", writedata)

For example, here is the contents of sdl2_sdlgfx.rst:

    .. module:: sdl2.sdlgfx
       :synopsis: SDL2_gfx library wrapper

    sdl2.sdlgfx - SDL2_gfx library wrapper
    ======================================
    The :mod:`sdl2.sdlgfx` module is a :mod:`ctypes`-based wrapper
    around the SDL2_gfx library. It wraps nearly all publicly accessible
    structures and functions of the SDL2_gfx library to be accessible from
    Python code.

    A detailed documentation about the behaviour of the different functions
    can found on the `SDL2_gfx project website

And output for the sdl2_sdlgfx.rst processing:

    ...
    writing output... [100%] modules/sdl2_sdlgfx                                   
    document
    target
    index
    section
    title
    #text
    paragraph
    #text
    reference
    literal
    #text
    #text
    reference
    literal
    #text
    #text
    paragraph
    #text
    reference
    #text
    target
    #text

    generating indices... genindex py-modindex
    ...

 
BTW, all module data is stored in `Environment.domaindata`.
Please check ``sphinx/domains/std.py`` as a usage sample.

Opened the file. Not sure what to look for.

Bram Geron

unread,
Jul 27, 2015, 9:14:14 AM7/27/15
to sphinx-dev, shimi...@gmail.com, tech...@gmail.com
This probably won't help you in the end, but check out the output of make pseudoxml. I've found it an enlightening way to inspect the node tree.

The Environment.domaindata file is probably a better source (but I have no experience with it).

Cheers, Bram
Reply all
Reply to author
Forward
0 new messages