diff options
author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-12-07 10:42:53 +0000 |
---|---|---|
committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-12-07 10:42:53 +0000 |
commit | 7524e3eb7861b3c7417cb003b98af51a67cce5b4 (patch) | |
tree | 08b564413ced28845bec03be36066efe35024b21 /sandbox/davidg/docutils/readers/python/pynodes.py | |
parent | f233f08fe5ba13ed408123b01de5147543dd93fe (diff) | |
download | docutils-7524e3eb7861b3c7417cb003b98af51a67cce5b4.tar.gz |
Move the orphaned python source reader to the sandbox.
The "python" reader is no longer maintained and (in its current form)
does not work with Python 3.
Documentation from RST docstrings can be generated with the Sphinx
"autodoc" extension (http://sphinx.pocoo.org/latest/ext/autodoc.html).
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@6495 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/davidg/docutils/readers/python/pynodes.py')
-rw-r--r-- | sandbox/davidg/docutils/readers/python/pynodes.py | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/sandbox/davidg/docutils/readers/python/pynodes.py b/sandbox/davidg/docutils/readers/python/pynodes.py new file mode 100644 index 000000000..c132114c4 --- /dev/null +++ b/sandbox/davidg/docutils/readers/python/pynodes.py @@ -0,0 +1,81 @@ +#! /usr/bin/env python +# $Id$ +# Author: David Goodger <goodger@python.org> +# Copyright: This module has been placed in the public domain. + +from docutils import nodes +from docutils.nodes import Element, TextElement, Structural, Inline, Part, \ + Text +import types + +# This is the parent class of all the other pynode classes: +class PythonStructural(Structural): pass + +# ===================== +# Structural Elements +# ===================== + +class module_section(PythonStructural, Element): pass +class class_section(PythonStructural, Element): pass +class class_base(PythonStructural, Element): pass +class method_section(PythonStructural, Element): pass +class attribute(PythonStructural, Element): pass +class function_section(PythonStructural, Element): pass +class class_attribute_section(PythonStructural, Element): pass +class class_attribute(PythonStructural, Element): pass +class expression_value(PythonStructural, Element): pass +class attribute(PythonStructural, Element): pass + +# Structural Support Elements +# --------------------------- + +class parameter_list(PythonStructural, Element): pass +class parameter_tuple(PythonStructural, Element): pass +class parameter_default(PythonStructural, TextElement): pass +class import_group(PythonStructural, TextElement): pass +class import_from(PythonStructural, TextElement): pass +class import_name(PythonStructural, TextElement): pass +class import_alias(PythonStructural, TextElement): pass +class docstring(PythonStructural, Element): pass + +# ================= +# Inline Elements +# ================= + +# These elements cannot become references until the second +# pass. Initially, we'll use "reference" or "name". + +class object_name(PythonStructural, TextElement): pass +class parameter_list(PythonStructural, TextElement): pass +class parameter(PythonStructural, TextElement): pass +class parameter_default(PythonStructural, TextElement): pass +class class_attribute(PythonStructural, TextElement): pass +class attribute_tuple(PythonStructural, TextElement): pass + +# ================= +# Unused Elements +# ================= + +# These were part of the model, and maybe should be in the future, but +# aren't now. +#class package_section(PythonStructural, Element): pass +#class module_attribute_section(PythonStructural, Element): pass +#class instance_attribute_section(PythonStructural, Element): pass +#class module_attribute(PythonStructural, TextElement): pass +#class instance_attribute(PythonStructural, TextElement): pass +#class exception_class(PythonStructural, TextElement): pass +#class warning_class(PythonStructural, TextElement): pass + + +# Collect all the classes we've written above +def install_node_class_names(): + node_class_names = [] + for name, var in globals().items(): + if (type(var) is types.ClassType + and issubclass(var, PythonStructural) \ + and name.lower() == name): + node_class_names.append(var.tagname or name) + # Register the new node names with GenericNodeVisitor and + # SpecificNodeVisitor: + nodes._add_node_class_names(node_class_names) +install_node_class_names() |