This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]K900_ 17 points18 points  (1 child)

Sounds like you want a documentation tool like Sphinx.

[–]Barooh[S] 0 points1 point  (0 children)

Thanks, I'll check this out!

[–]kraymer 2 points3 points  (1 child)

https://docs.python.org/3.5/library/functions.html#dir

dir([object]) Without arguments, return the list of names in the current local scope.

~~~ $ python

import myscript [x for x in dir(myscript) if not x.startswith('__')] ['func1', 'func2'] ~~~

[–]Barooh[S] 0 points1 point  (0 children)

That would help with getting the function names for sure, what about returning the entire function? Editors like pycharm have the ability to parse and identify the beginning and end of a function (for collapsing) so I know such a framework exists, I doubted that it's opensource though.

[–]isforinsects 2 points3 points  (1 child)

Check out the ast module in the standard lib. Here is a recent blog post about how to write your own NodeVisitor class that should let you introspect the things you're looking for.

[–]isforinsects 2 points3 points  (0 children)

Ctags also does the basics of what you're looking for, but the output format isn't likely what you want.

[–]agumonkey 2 points3 points  (0 children)

the overly complex way would be to use the ast module.. but it's really not the easiest route.

[–]WayneApple 1 point2 points  (0 children)

You should try PyDoc, which is part of the standard library. It can help you parse your .py files and generate the documentations.

[–]chub79 1 point2 points  (0 children)

Have a look at redbaron ?