예제 #1
0
    def __init__(self,
                 chapter: str,
                 title: str,
                 text: str,
                 submodule,
                 installed: bool = True):
        self.chapter = chapter
        self.doc = DjangoDoc(text, title, None)
        self.in_guide = False
        self.installed = installed
        self.slug = slugify(title)
        self.section = submodule
        self.slug = slugify(title)
        self.subsections = []
        self.subsections_by_slug = {}
        self.title = title

        # FIXME: Sections never are operators. Subsections can have
        # operators though.  Fix up the view and searching code not to
        # look for the operator field of a section.
        self.operator = False

        if text.count("<dl>") != text.count("</dl>"):
            raise ValueError("Missing opening or closing <dl> tag in "
                             "{} documentation".format(title))
        # print("YYY Adding section", title)
        chapter.sections_by_slug[self.slug] = self
예제 #2
0
    def __init__(self,
                 chapter,
                 title: str,
                 text: str,
                 operator,
                 installed=True,
                 in_guide=False):
        self.chapter = chapter
        self.in_guide = in_guide
        self.installed = installed
        self.operator = operator
        self.slug = slugify(title)
        self.subsections = []
        self.subsections_by_slug = {}
        self.title = title

        if text.count("<dl>") != text.count("</dl>"):
            raise ValueError("Missing opening or closing <dl> tag in "
                             "{} documentation".format(title))

        # Needs to come after self.chapter is initialized since
        # XMLDoc uses self.chapter.
        self.doc = DjangoDoc(text, title, self)

        chapter.sections_by_slug[self.slug] = self
예제 #3
0
 def __init__(self, doc, title, is_reference=False):
     self.doc = doc
     self.title = title
     self.slug = slugify(title)
     self.chapters = []
     self.chapters_by_slug = {}
     self.is_reference = is_reference
     self.is_appendix = False
     doc.parts_by_slug[self.slug] = self
예제 #4
0
 def __init__(self, part: str, title: str, doc=None):
     self.doc = doc
     self.guide_sections = []
     self.part = part
     self.sections = []
     self.sections_by_slug = {}
     self.slug = slugify(title)
     self.title = title
     part.chapters_by_slug[self.slug] = self
예제 #5
0
    def __init__(
        self,
        chapter,
        section,
        title,
        text,
        operator=None,
        installed=True,
        in_guide=False,
    ):
        """
        Information that goes into a subsection object. This can be a written text, or
        text extracted from the docstring of a builtin module or class.

        About some of the parameters...

        Some built-in classes are Operators. These are documented in a
        slightly special way.

        Some built-in require special libraries. When those libraries are not available,
        parameter "installed" is False.

        Some of the subsections are contained in a grouping module and need special work to
        get the grouping module name correct.

        For example the Chapter "Colors" is a module so the docstring text for it is in
        mathics/builtin/colors/__init__.py . In mathics/builtin/colors/named-colors.py we have
        the "section" name for the class Read (the subsection) inside it.
        """

        self.doc = DjangoDoc(text, title, section)
        self.chapter = chapter
        self.installed = installed
        self.operator = operator

        self.section = section
        self.slug = slugify(title)
        self.title = title

        if in_guide:
            # Tests haven't been picked out yet from the doc string yet.
            # Gather them here.
            self.items = gather_tests(self.text, DjangoDocTests, DjangoDocTest,
                                      DjangoDocText, key_prefix)
        else:
            self.items = []

        if text.count("<dl>") != text.count("</dl>"):
            raise ValueError("Missing opening or closing <dl> tag in "
                             "{} documentation".format(title))
        self.section.subsections_by_slug[self.slug] = self