On Wed, Mar 21, 2018 at 3:52 PM, silverj87 wrote: > Hi all! > > Does anyone know of a way to use members of sphinx to pull doc string > information for use within another code?
You should probably have a look at those: https://ipython.readthedocs.io/en/stable/api/generated/IPython.core.oinspect.html https://github.com/spyder-ide/docrepr https://doc.sagemath.org/html/en/reference/notebook/sagenb/misc/sphinxify.html If you just want to parse reStructuredText without using Sphinx, you can try the "Parser" class from docutils.parsers.rst: https://github.com/docutils/docutils/blob/master/docutils/docutils/parsers/rst/__init__.py This is the same parser that Sphinx is using. cheers, Matthias > I'm trying to write a decorator that will parse the reST doc strings for > information about param descriptions/types and log them into a database for > use in other parts of the code. I realize that I mainly just need the reST > parsing functions out of sphinx but from my review of the code they all > seemed linked to the sphinx environment for creating the docs... I'm having > a hard time trying to figure out how I can use it outside of its intended > framework. > > Example: > def doc(x): > """ > Description is here ;-) > > :param x: X is some variable > :type x: int > :return: Return some stuff > :rtype: float > """ > pass > > What I'd like to get out of the method to parse would be a dictionary > similar to: > > { > "description": "Description is here ;-)", > "inputs":{"x":{"description":"X is some variable"},"type":int}, > "return":{"description":"Return some stuff"},"type":float} > } > > Anyone know of a way to use sphinx's already awesome methods to do something > like this? > > -- > 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 sphinx-users+unsubscr...@googlegroups.com. > To post to this group, send email to sphinx-users@googlegroups.com. > Visit this group at https://groups.google.com/group/sphinx-users. > For more options, visit https://groups.google.com/d/optout. -- 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 sphinx-users+unsubscr...@googlegroups.com. To post to this group, send email to sphinx-users@googlegroups.com. Visit this group at https://groups.google.com/group/sphinx-users. For more options, visit https://groups.google.com/d/optout.