Commits

Carl Friedrich Bolz  committed 4cd84b6

whack until we get documentation for all config options in a sphinx style. some
of this is not pretty nor proper, but I want to spend no more time on this.

  • Participants
  • Parent commits 2841a5a
  • Branches documentation-cleanup

Comments (0)

Files changed (7)

 ^pypy/module/cpyext/test/.+\.manifest$
 ^pypy/module/test_lib_pypy/ctypes_tests/.+\.o$
 ^pypy/doc/.+\.html$
+^pypy/doc/config/.+\.rst$
 ^pypy/doc/basicblock\.asc$
 ^pypy/doc/.+\.svninfo$
 ^pypy/translator/c/src/libffi_msvc/.+\.obj$

File pypy/config/makerestdoc.py

         fullpath = get_fullpath(self, path)
         result = Rest(
             Title(fullpath, abovechar="=", belowchar="="),
-            Directive("contents"),
-            Paragraph(Link("back to parent", path + ".html")),
-            Title("Basic Option Information"),
             ListItem(Strong("name:"), self._name),
             ListItem(Strong("description:"), self.doc))
         if self.cmdline is not None:
     def make_rest_doc(self, path=""):
         fullpath = get_fullpath(self, path)
         content = Rest(
-            Title(fullpath, abovechar="=", belowchar="="),
-            Directive("contents"))
-        if path:
-            content.add(
-                Paragraph(Link("back to parent", path + ".html")))
+            Title(fullpath, abovechar="=", belowchar="="))
+        toctree = []
+        for child in self._children:
+            subpath = fullpath + "." + child._name
+            toctree.append(subpath)
+        content.add(Directive("toctree", *toctree, maxdepth=4))
         content.join(
-            Title("Basic Option Information"),
             ListItem(Strong("name:"), self._name),
-            ListItem(Strong("description:"), self.doc),
-            Title("Sub-Options"))
+            ListItem(Strong("description:"), self.doc))
         stack = []
-        prefix = fullpath
         curr = content
         config = Config(self)
-        for ending in self.getpaths(include_groups=True):
-            subpath = fullpath + "." + ending
-            while not (subpath.startswith(prefix) and
-                       subpath[len(prefix)] == "."):
-                curr, prefix = stack.pop()
-            print subpath, fullpath, ending, curr
-            sub, step = config._cfgimpl_get_home_by_path(ending)
-            doc = getattr(sub._cfgimpl_descr, step).doc
-            if doc:
-                new = curr.add(ListItem(Link(subpath + ":", subpath + ".html"),
-                                        Em(doc)))
-            else:
-                new = curr.add(ListItem(Link(subpath + ":", subpath + ".html")))
-            stack.append((curr, prefix))
-            prefix = subpath
-            curr = new
         return content
 
 

File pypy/config/test/test_makerestdoc.py

     config = Config(descr)
     txt = descr.make_rest_doc().text()
     
-    result = {"": checkrest(txt, descr._name + ".txt")}
+    result = {"": txt}
     for path in config.getpaths(include_groups=True):
         subconf, step = config._cfgimpl_get_home_by_path(path)
         fullpath = (descr._name + "." + path)
         prefix = fullpath.rsplit(".", 1)[0]
         txt = getattr(subconf._cfgimpl_descr, step).make_rest_doc(
                 prefix).text()
-        result[path] = checkrest(txt, fullpath + ".txt")
+        result[path] = txt
     return result
 
 def test_simple():
             ChoiceOption("bar", "more doc", ["a", "b", "c"],
                          default="a")])
     result = generate_html(descr)
-    assert "more doc" in result[""]
 
 def test_cmdline_overview():
     descr = OptionDescription("foo", "doc", [

File pypy/doc/Makefile

 	-rm -rf $(BUILDDIR)/*
 
 html:
+	python config/generate.py
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
 	@echo
 	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
 
 dirhtml:
+	python config/generate.py
 	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
 	@echo
 	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
 
 pickle:
+	python config/generate.py
 	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
 	@echo
 	@echo "Build finished; now you can process the pickle files."
 
 json:
+	python config/generate.py
 	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
 	@echo
 	@echo "Build finished; now you can process the JSON files."
 
 htmlhelp:
+	python config/generate.py
 	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
 	@echo
 	@echo "Build finished; now you can run HTML Help Workshop with the" \
 	      ".hhp project file in $(BUILDDIR)/htmlhelp."
 
 qthelp:
+	python config/generate.py
 	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
 	@echo
 	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
 	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PyPy.qhc"
 
 latex:
+	python config/generate.py
 	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
 	@echo
 	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
 	      "run these through (pdf)latex."
 
 changes:
+	python config/generate.py
 	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
 	@echo
 	@echo "The overview file is in $(BUILDDIR)/changes."
 
 linkcheck:
+	python config/generate.py
 	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
 	@echo
 	@echo "Link check complete; look for any errors in the above output " \
 	      "or in $(BUILDDIR)/linkcheck/output.txt."
 
 doctest:
+	python config/generate.py
 	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
 	@echo "Testing of doctests in the sources finished, look at the " \
 	      "results in $(BUILDDIR)/doctest/output.txt."

File pypy/doc/config/generate.py

                    ]
 start_to_descr = dict([(descr._name, descr) for descr in all_optiondescrs])
 
+def make_rst(basename):
+    txtpath = thisdir.join(basename)
+    txtpath.ensure()
+    rstpath = txtpath.new(ext=".rst")
+
+    fullpath = txtpath.purebasename
+    start = fullpath.split(".")[0]
+    path = fullpath.rsplit(".", 1)[0]
+    basedescr = start_to_descr.get(start)
+    if basedescr is None:
+        return
+    if fullpath.count(".") == 0:
+        descr = basedescr
+        path = ""
+    else:
+        conf = config.Config(basedescr)
+        subconf, step = conf._cfgimpl_get_home_by_path(
+                fullpath.split(".", 1)[1])
+        descr = getattr(subconf._cfgimpl_descr, step)
+    text = unicode(descr.make_rest_doc(path).text())
+    if txtpath.check(file=True):
+        content = txtpath.read()
+        if content:
+            text += "\n\n"
+            text = u"%s\n\n%s" % (text, unicode(txtpath.read(), "utf-8"))
+    rstpath.write(text.encode("utf-8"))
+
 
 thisdir = py.path.local(__file__).dirpath()
 
     prefix = descr._name
     c = config.Config(descr)
     thisdir.join(prefix + ".txt").ensure()
+    make_rst(prefix + ".txt")
     for p in c.getpaths(include_groups=True):
         basename = prefix + "." + p + ".txt"
-        txtpath = thisdir.join(basename)
-        txtpath.ensure()
-        rstpath = txtpath.new(ext=".rst")
-
-        fullpath = txtpath.purebasename
-        start = fullpath.split(".")[0]
-        path = fullpath.rsplit(".", 1)[0]
-        basedescr = start_to_descr.get(start)
-        if basedescr is None:
-            continue
-        if fullpath.count(".") == 0:
-            descr = basedescr
-            path = ""
-        else:
-            conf = config.Config(basedescr)
-            subconf, step = conf._cfgimpl_get_home_by_path(
-                    fullpath.split(".", 1)[1])
-            descr = getattr(subconf._cfgimpl_descr, step)
-        text = unicode(descr.make_rest_doc(path).text())
-        if txtpath.check(file=True):
-            content = txtpath.read()
-            if content:
-                text += "\nDescription\n==========="
-                text = u"%s\n\n%s" % (text, unicode(txtpath.read(), "utf-8"))
-        print path
-        print "***************************"
-        print text
-        rstpath.write(text.encode("utf-8"))
+        make_rst(basename)

File pypy/tool/rest/rest.py

         pass
 
 def convert_rest_html(source, source_path, stylesheet=None, encoding='latin1'):
-    from pypy.tool.rest import directive
     """ return html latin1-encoded document for the given input. 
         source  a ReST-string
         sourcepath where to look for includes (basically)
         stylesheet path (to be used if any)
     """
     from docutils.core import publish_string
-    directive.set_backend_and_register_directives("html")
     kwargs = {
         'stylesheet' : stylesheet, 
         'stylesheet_path': None,

File pypy/tool/rest/rst.py

     indent = '   '
     def __init__(self, name, *args, **options):
         self.name = name
-        self.content = options.pop('content', [])
-        children = list(args)
-        super(Directive, self).__init__(*children)
+        self.content = args
+        super(Directive, self).__init__()
         self.options = options
         
     def text(self):
         # XXX not very pretty...
-        namechunksize = len(self.name) + 2
-        self.children.insert(0, Text('X' * namechunksize))
-        txt = super(Directive, self).text()
-        txt = '.. %s::%s' % (self.name, txt[namechunksize + 3:],)
-        options = '\n'.join(['   :%s: %s' % (k, v) for (k, v) in
+        txt = '.. %s::' % (self.name,)
+        options = '\n'.join(['    :%s: %s' % (k, v) for (k, v) in
                              self.options.iteritems()])
         if options:
             txt += '\n%s' % (options,)
         if self.content:
             txt += '\n'
             for item in self.content:
-                assert item.parentclass == Rest, 'only top-level items allowed'
-                assert not item.indent
-                item.indent = '   '
-                txt += '\n' + item.text()
+                txt += '\n    ' + item
         
         return txt