rst2xml with sphinx?

54 views
Skip to first unread message

Michael Schlenker

unread,
Jun 8, 2012, 11:11:49 AM6/8/12
to sphin...@googlegroups.com
Hi,

docutils offers a rst2xml.py script, which writes out the internal
doctree as xml. When using this with Sphinx .rst files, it obviously
does not know about all the extra roles and directives and adds lots
of warnings/system-messages about those instead of nice xml nodes.

I managed to get it to work with simple Sphinx generated sources by
registering the basic nodes via adding a few imports:

# register all the sphinx nodes/roles/directives
from sphinx import addnodes, roles
from sphinx.directives import code, other

in the rst2xml.py script, but i did not find the proper way to register
:ref: or any of the domain specific things like :py:class: / .. py:class::.

Did anyone already hack something up that does it, or is my best bet to
extract the needed code from sphinx/application.py?

Michael

--
Michael Schlenker
Software Architect

CONTACT Software GmbH Tel.: +49 (421) 20153-80
Wiener Straï¿œe 1-3 Fax: +49 (421) 20153-41
28359 Bremen
http://www.contact.de/ E-Mail: m...@contact.de

Sitz der Gesellschaft: Bremen
Geschï¿œftsfï¿œhrer: Karl Heinz Zachries, Ralf Holtgrefe
Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215

Takayuki Shimizukawa

unread,
Jun 9, 2012, 1:57:22 AM6/9/12
to sphin...@googlegroups.com
Hi Michael,

If you want to get node-tree structure, you can dump pseudo-xml format
from `*.doctree` file in the `_build/doctree/` folder.

Dump script is here:
http://sphinx-users.jp/reverse-dict/system/doctree.html

.. Is it useful if we can execute ``make pseudo-xml`` ?

Regards.
--
Takayuki SHIMIZUKAWA
Sphinx-users.jp


2012/6/8 Michael Schlenker <m...@contact.de>:
> Hi,
>
> docutils offers a rst2xml.py script, which writes out the internal
> doctree as xml. When using this with Sphinx .rst files, it obviously
> does not know about all the extra roles and directives and adds lots
> of warnings/system-messages about those instead of nice xml nodes.
>
> I managed to get it to work with simple Sphinx generated sources by
> registering the basic nodes via adding a few imports:
>
>  # register all the sphinx nodes/roles/directives
>  from sphinx import addnodes, roles
>  from sphinx.directives import code, other
>
> in the rst2xml.py script, but i did not find the proper way to register
> :ref: or any of the domain specific things like :py:class: / .. py:class::.
>
> Did anyone already hack something up that does it, or is my best bet to
> extract the needed code from sphinx/application.py?
>
> Michael
>
> --
> Michael Schlenker
> Software Architect
>
> CONTACT Software GmbH           Tel.:   +49 (421) 20153-80
> Wiener Straße 1-3               Fax:    +49 (421) 20153-41
> 28359 Bremen
> http://www.contact.de/          E-Mail: m...@contact.de
>
> Sitz der Gesellschaft: Bremen
> Geschäftsführer: Karl Heinz Zachries, Ralf Holtgrefe
> Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215
>
> --
> You received this message because you are subscribed to the Google Groups "sphinx-dev" group.
> To post to this group, send email to sphin...@googlegroups.com.
> To unsubscribe from this group, send email to sphinx-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en.
Reply all
Reply to author
Forward
0 new messages