[Epydoc-commits] SF.net SVN: epydoc: [1170] trunk/epydoc/src/epydoc/markup/restructuredtext.py
Brought to you by:
edloper
From: <ed...@us...> - 2006-04-05 17:11:42
|
Revision: 1170 Author: edloper Date: 2006-04-05 10:11:38 -0700 (Wed, 05 Apr 2006) ViewCVS: http://svn.sourceforge.net/epydoc/?rev=1170&view=rev Log Message: ----------- - Added a callgraph directive to restructuredtext markup parser Modified Paths: -------------- trunk/epydoc/src/epydoc/markup/restructuredtext.py Modified: trunk/epydoc/src/epydoc/markup/restructuredtext.py =================================================================== --- trunk/epydoc/src/epydoc/markup/restructuredtext.py 2006-04-05 16:58:42 UTC (rev 1169) +++ trunk/epydoc/src/epydoc/markup/restructuredtext.py 2006-04-05 17:11:38 UTC (rev 1170) @@ -539,6 +539,7 @@ ###################################################################### #{ Graph Generation Directives ###################################################################### +# See http://docutils.sourceforge.net/docs/howto/rst-directives.html class dotgraph(docutils.nodes.image): """ @@ -593,7 +594,7 @@ else: title = '' return dotgraph(_construct_digraph, title, options.get('caption'), '\n'.join(content)) -digraph_directive.arguments = (0, 1, 1) +digraph_directive.arguments = (0, 1, True) digraph_directive.options = {'caption': directives.unchanged} digraph_directive.content = True directives.register_directive('digraph', digraph_directive) @@ -689,3 +690,24 @@ """Graph generator for L{importgraph_directive}""" modules = [d for d in docindex.root if isinstance(d, ModuleDoc)] return import_graph(modules, docindex, linker, context, **options) + +def callgraph_directive(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + return dotgraph(_construct_callgraph, arguments, options) +callgraph_directive.arguments = (0, 1, True) +callgraph_directive.options = {'dir': _dir_option, + 'add_callers': directives.flag, + 'add_callees': directives.flag} +callgraph_directive.content = False +directives.register_directive('callgraph', callgraph_directive) + +def _construct_callgraph(docindex, context, linker, arguments, options): + """Graph generator for L{callgraph_directive}""" + if len(arguments) == 1: + docs = [docindex.find(name, context) for name in + arguments[0].replace(',',' ').split()] + docs = [doc for doc in docs if doc is not None] + else: + docs = [context] + return call_graph(docs, docindex, linker, context, **options) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |