Permalink
Browse files

Fixing abandoned "items" to fix latex output

The more targetted directives were entering into the rendering hierarchy
at the MemberDefTypeSubRenderer level. The class and its subclasses
return a definition_list_item object which was not being put under an
appropriate definition_list.

This is an error that it seems the html output was fairly forgiving of,
but the latex output complained about \items that were outside of a
\begin \end scope.

So here we change our directives so that they wrap the returned nodes in
a definition_list before passing them back to Sphinx.

This seems to solve the problem of the isolated items but the latex
output for the testsuite is currently still failing as the "nutshell"
example contains too much indented hierarchy and so exceeds latex's
built in limit of 6 nested listing scopes.

I'm not entirely sure what it do about this. For the benefit of the
testsuite I might have to edit the nutshell example, but that only
delays the issue.
  • Loading branch information...
Michael Jones
Michael Jones committed Jul 5, 2011
1 parent a3ec849 commit 5d76764e0a95b7b28cbe3cec6f3936b8b4f66407
Showing with 167 additions and 53 deletions.
  1. +79 −20 breathe/__init__.py
  2. +88 −33 testsuite/Makefile
View
@@ -98,9 +98,9 @@ def run(self):
target_handler,
)
object_renderer = renderer_factory.create_renderer(self.root_data_object, data_object)
- nodes = object_renderer.render()
+ node_list = object_renderer.render()
- return nodes
+ return node_list
class DoxygenFunctionDirective(BaseDirective):
@@ -159,9 +159,12 @@ def run(self):
target_handler,
)
object_renderer = renderer_factory.create_renderer(self.root_data_object, data_object)
- nodes = object_renderer.render()
+ node_list = object_renderer.render()
- return nodes
+ # Wrap the result in a definition_list as the MemberDefTypeSubRenderer,
+ # which is the base class for the function renderer, returns a
+ # definition list item
+ return [nodes.definition_list("", *node_list)]
class DoxygenClassDirective(BaseDirective):
@@ -219,9 +222,9 @@ def run(self):
)
object_renderer = renderer_factory.create_renderer(self.root_data_object, data_object)
- nodes = object_renderer.render()
+ node_list = object_renderer.render()
- return nodes
+ return node_list
class DoxygenFileDirective(BaseDirective):
@@ -270,7 +273,7 @@ def run(self):
self.state.document,
self.options,
)
- nodes = []
+ node_list = []
for data_object in matches:
renderer_factory = renderer_factory_creator.create_factory(
@@ -282,9 +285,9 @@ def run(self):
)
object_renderer = renderer_factory.create_renderer(self.root_data_object, data_object)
- nodes.extend(object_renderer.render())
+ node_list.extend(object_renderer.render())
- return nodes
+ return node_list
class DoxygenBaseDirective(BaseDirective):
@@ -337,9 +340,9 @@ def run(self):
)
object_renderer = renderer_factory.create_renderer(self.root_data_object, data_object)
- nodes = object_renderer.render()
+ node_list = object_renderer.render()
- return nodes
+ return node_list
class DoxygenStructDirective(DoxygenBaseDirective):
@@ -362,7 +365,68 @@ def create_matcher_stack(self, namespace, name):
)
-class DoxygenVariableDirective(DoxygenBaseDirective):
+# This class is the same as the DoxygenBaseDirective above, except that it
+# wraps the output in a definition_list before passing it back. This should be
+# abstracted in a far nicely way to avoid repeating so much code
+class DoxygenBaseItemDirective(BaseDirective):
+
+ required_arguments = 1
+ optional_arguments = 1
+ option_spec = {
+ "path": unchanged_required,
+ "project": unchanged_required,
+ "outline": flag,
+ "no-link": flag,
+ }
+ has_content = False
+
+ def run(self):
+
+ try:
+ namespace, name = self.arguments[0].rsplit("::", 1)
+ except ValueError:
+ namespace, name = "", self.arguments[0]
+
+ project_info = self.project_info_factory.create_project_info(self.options)
+
+ finder = self.finder_factory.create_finder(project_info)
+
+ matcher_stack = self.create_matcher_stack(namespace, name)
+
+ try:
+ data_object = finder.find_one(matcher_stack)
+ except NoMatchesError, e:
+ display_name = "%s::%s" % (namespace, name) if namespace else name
+ warning = ('doxygen%s: Cannot find %s "%s" in doxygen xml output for project "%s" from directory: %s'
+ % (self.kind, self.kind, display_name, project_info.name(), project_info.path()))
+ return [docutils.nodes.warning("", docutils.nodes.paragraph("", "", docutils.nodes.Text(warning))),
+ self.state.document.reporter.warning(warning, line=self.lineno)]
+
+ target_handler = self.target_handler_factory.create(self.options, project_info, self.state.document)
+ filter_ = self.filter_factory.create_outline_filter(self.options)
+ renderer_factory_creator = self.renderer_factory_creator_constructor.create_factory_creator(
+ project_info,
+ self.state.document,
+ self.options,
+ )
+ renderer_factory = renderer_factory_creator.create_factory(
+ data_object,
+ self.state,
+ self.state.document,
+ filter_,
+ target_handler,
+ )
+ object_renderer = renderer_factory.create_renderer(self.root_data_object, data_object)
+
+ node_list = object_renderer.render()
+
+ # Wrap the result in a definition_list as all the subclasses of this
+ # directive target renderers derived from MemberDefTypeSubRenderer and
+ # that returns a definition item
+ return [nodes.definition_list("", *node_list)]
+
+
+class DoxygenVariableDirective(DoxygenBaseItemDirective):
kind = "variable"
@@ -376,8 +440,7 @@ def create_matcher_stack(self, namespace, name):
"member"
)
-
-class DoxygenDefineDirective(DoxygenBaseDirective):
+class DoxygenDefineDirective(DoxygenBaseItemDirective):
kind = "define"
@@ -391,8 +454,7 @@ def create_matcher_stack(self, namespace, name):
"member"
)
-
-class DoxygenEnumDirective(DoxygenBaseDirective):
+class DoxygenEnumDirective(DoxygenBaseItemDirective):
kind = "enum"
@@ -406,8 +468,7 @@ def create_matcher_stack(self, namespace, name):
"member"
)
-
-class DoxygenTypedefDirective(DoxygenBaseDirective):
+class DoxygenTypedefDirective(DoxygenBaseItemDirective):
kind = "typedef"
@@ -420,8 +481,6 @@ def create_matcher_stack(self, namespace, name):
},
"member"
)
-
-
# Setup Administration
# --------------------
View
@@ -5,71 +5,126 @@
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
+BUILDDIR = build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS = -P -a -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+ALLSPHINXOPTS = -P -a -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
-.PHONY: help clean html web pickle htmlhelp latex changes linkcheck
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
help:
@echo "Please use \`make <target>' where <target> is one of"
- @echo " html to make standalone HTML files"
- @echo " pickle to make pickle files"
- @echo " json to make JSON files"
- @echo " htmlhelp to make HTML files and a HTML help project"
- @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
- @echo " changes to make an overview over all changed/added/deprecated items"
- @echo " linkcheck to check all external links for integrity"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
- -rm -rf build/*
+ -rm -rf $(BUILDDIR)/*
html:
- mkdir -p build/html build/doctrees
- $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
- @echo "Build finished. The HTML pages are in build/html."
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
- mkdir -p build/pickle build/doctrees
- $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
-web: pickle
-
json:
- mkdir -p build/json build/doctrees
- $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) build/json
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
- mkdir -p build/htmlhelp build/doctrees
- $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
- ".hhp project file in build/htmlhelp."
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/asd.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/asd.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/asd"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/asd"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
- mkdir -p build/latex build/doctrees
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ make -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
- @echo "Build finished; the LaTeX files are in build/latex."
- @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
- "run these through (pdf)latex."
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
changes:
- mkdir -p build/changes build/doctrees
- $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
- @echo "The overview file is in build/changes."
+ @echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
- mkdir -p build/linkcheck build/doctrees
- $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
- "or in build/linkcheck/output.txt."
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."

0 comments on commit 5d76764

Please sign in to comment.