📄 pynodes.py
字号:
#! /usr/bin/env python""":Author: David Goodger:Contact: goodger@users.sourceforge.net:Revision: $Revision: 1881 $:Date: $Date: 2004-03-24 00:21:11 +0100 (Wed, 24 Mar 2004) $:Copyright: This module has been placed in the public domain."""from docutils import nodesfrom docutils.nodes import Element, TextElement, Structural, Inline, Part, \ Textimport 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): passclass class_base(PythonStructural, Element): passclass method_section(PythonStructural, Element): passclass attribute(PythonStructural, Element): passclass function_section(PythonStructural, Element): passclass class_attribute_section(PythonStructural, Element): passclass class_attribute(PythonStructural, Element): passclass expression_value(PythonStructural, Element): passclass attribute(PythonStructural, Element): pass# Structural Support Elements# ---------------------------class parameter_list(PythonStructural, Element): passclass parameter_tuple(PythonStructural, Element): passclass parameter_default(PythonStructural, TextElement): passclass import_group(PythonStructural, TextElement): passclass import_from(PythonStructural, TextElement): passclass import_name(PythonStructural, TextElement): passclass import_alias(PythonStructural, TextElement): passclass 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): passclass parameter_list(PythonStructural, TextElement): passclass parameter(PythonStructural, TextElement): passclass parameter_default(PythonStructural, TextElement): passclass class_attribute(PythonStructural, TextElement): passclass 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 abovedef 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()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -