On Thursday, June 6, 2013 2:05:56 PM UTC-4, Kristin Barber wrote:
> Can Sphinx handle headings in docstrings for auto-generation?
>
> Attempting to use a section heading in a docstring gives me this error:
>
> SEVERE: Unexpected section title.
>
There was a similar thread with some conversation in 2009[1]. AFAICT,
Sphinx hasn't learned to handle sections in docstrings since then. Here's a
quick hack that seems to work under very light testing on my machine. I'm
sure I'll find out why this is a terrible idea soon. ;-)
[mlm@matt-mapmyfitness-macbook:~/w/mlm/sphinx]
$ hg diff
diff -r fd52c8c8aa2d sphinx/directives/__init__.py
--- a/sphinx/directives/__init__.py Tue Jun 11 08:19:52 2013 +0900
+++ b/sphinx/directives/__init__.py Tue Jun 11 22:15:57 2013 -0400
@@ -161,7 +161,8 @@
# needed for association of version{added,changed} directives
self.env.temp_data['object'] = self.names[0]
self.before_content()
- self.state.nested_parse(self.content, self.content_offset,
contentnode)
+ from sphinx.util import nodes
+ nodes.nested_parse_with_titles(self.state, self.content,
contentnode)
DocFieldTransformer(self).transform_all(contentnode)
self.env.temp_data['object'] = None
self.after_content()
diff -r fd52c8c8aa2d sphinx/ext/autodoc.py
--- a/sphinx/ext/autodoc.py Tue Jun 11 08:19:52 2013 +0900
+++ b/sphinx/ext/autodoc.py Tue Jun 11 22:15:57 2013 -0400
@@ -219,7 +219,7 @@
#: order if autodoc_member_order is set to 'groupwise'
member_order = 0
#: true if the generated content may contain titles
- titles_allowed = False
+ titles_allowed = True
option_spec = {'noindex': bool_option}
@@ -1360,7 +1360,7 @@
self.state.memo.reporter = AutodocReporter(self.result,
self.state.memo.reporter)
- if documenter.titles_allowed:
+ if True: #documenter.titles_allowed:
node = nodes.section()
# necessary so that the child nodes get the right source/line
set
node.document = self.state.document
[1]: https://groups.google.com/d/msg/sphinx-users/236vogwUZdE/5HH21HU7-6oJ
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sphinx-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.