Пример #1
0
 def _build_attributes_autosummary(self):
     from abjad.tools import documentationtools
     pieces = []
     attributes = []
     attributes.extend(self.readonly_properties)
     attributes.extend(self.readwrite_properties)
     attributes.extend(self.methods)
     attributes.extend(self.class_methods)
     attributes.extend(self.static_methods)
     attributes.sort(key=lambda x: x.name)
     attributes.extend(self.special_methods)
     autosummary = documentationtools.ReSTAutosummaryDirective()
     for attribute in attributes:
         autosummary.append('~{}.{}'.format(
             self.module_name,
             attribute.name,
         ))
     html_only = documentationtools.ReSTOnlyDirective(argument='html')
     html_only.append(
         documentationtools.ReSTHeading(
             level=3,
             text='Attribute summary',
         ))
     html_only.append(autosummary)
     pieces.append(html_only)
     return pieces
Пример #2
0
 def _build_autosummary_section(self, banner, documenters):
     from abjad.tools import documentationtools
     result = []
     heading = documentationtools.ReSTHeading(
         level=3,
         text=banner,
     )
     result.append(heading)
     autosummary = documentationtools.ReSTAutosummaryDirective()
     for documenter in documenters:
         autosummary.append('~{}'.format(documenter.module_name))
     result.append(autosummary)
     return result
Пример #3
0
 def _build_attributes_autosummary(
     self,
     cls,
     class_methods,
     data,
     inherited_attributes,
     methods,
     readonly_properties,
     readwrite_properties,
     special_methods,
     static_methods,
 ):
     r'''
     '''
     from abjad.tools import documentationtools
     result = []
     attributes = []
     attributes.extend(readonly_properties)
     attributes.extend(readwrite_properties)
     attributes.extend(methods)
     attributes.extend(class_methods)
     attributes.extend(static_methods)
     attributes.sort(key=lambda x: x.name)
     attributes.extend(special_methods)
     if attributes:
         autosummary = documentationtools.ReSTAutosummaryDirective()
         for attribute in attributes:
             autosummary.append('~{}.{}.{}'.format(
                 cls.__module__,
                 cls.__name__,
                 attribute.name,
             ))
         html_only = documentationtools.ReSTOnlyDirective(argument='html')
         html_only.append(
             documentationtools.ReSTHeading(
                 level=3,
                 text='Attribute summary',
             ))
         html_only.append(autosummary)
         result.append(html_only)
     return result
Пример #4
0
 def _get_tools_package_rst(self, tools_package):
     from abjad.tools import documentationtools
     classes, functions = self._get_tools_package_contents(
         tools_package,
         )
     document = documentationtools.ReSTDocument()
     if self.__class__.__name__.startswith('ScoreLibrary'):
         heading = documentationtools.ReSTHeading(
             level=2,
             text=tools_package.__name__,
             )
     else:
         heading = documentationtools.ReSTHeading(
             level=2,
             text=tools_package.__name__.split('.')[-1],
             )
     document.append(heading)
     automodule_directive = documentationtools.ReSTAutodocDirective(
         argument=tools_package.__name__,
         directive='automodule',
         )
     document.append(automodule_directive)
     ignored_classes = self._get_ignored_classes()
     classes = [_ for _ in classes if _ not in ignored_classes]
     if not self.__class__.__name__.startswith('ScoreLibrary'):
         if classes:
             rule = documentationtools.ReSTHorizontalRule()
             document.append(rule)
             lineage_heading = documentationtools.ReSTHeading(
                 level=3,
                 text='Lineage',
                 )
             document.append(lineage_heading)
             lineage_graph = self._get_tools_package_graph(tools_package)
             graphviz_directive = documentationtools.ReSTGraphvizDirective(
                 graph=lineage_graph,
                 )
             graphviz_container = documentationtools.ReSTDirective(
                 directive='container',
                 argument='graphviz',
                 )
             graphviz_container.append(graphviz_directive)
             document.append(graphviz_container)
     if classes:
         sections = {}
         for cls in classes:
             documentation_section = getattr(
                 cls,
                 '__documentation_section__',
                 None,
                 )
             if documentation_section is None:
                 #if issubclass(cls, enum.Enum):
                 #    documentation_section = 'Enumerations'
                 #elif issubclass(cls, Exception):
                 if issubclass(cls, Exception):
                     documentation_section = 'Errors'
                 else:
                     documentation_section = 'Classes'
                 if inspect.isabstract(cls):
                     documentation_section = 'Abstract Classes'
             if documentation_section not in sections:
                 sections[documentation_section] = []
             sections[documentation_section].append(cls)
         section_names = sorted(sections)
         if 'Main Classes' in sections:
             section_names.remove('Main Classes')
             section_names.insert(0, 'Main Classes')
         if 'Errors' in sections:
             section_names.remove('Errors')
             section_names.append('Errors')
         for section_name in section_names:
             rule = documentationtools.ReSTHorizontalRule()
             document.append(rule)
             heading = documentationtools.ReSTHeading(
                 level=3,
                 text=section_name,
                 )
             document.append(heading)
             toc = documentationtools.ReSTTOCDirective(
                 options={
                     'hidden': True,
                     },
                 )
             for cls in sections[section_name]:
                 class_name = cls.__name__
                 if class_name == 'Index':
                     class_name = '_Index'
                 toc_item = documentationtools.ReSTTOCItem(
                     text=class_name,
                     )
                 toc.append(toc_item)
             document.append(toc)
             autosummary = documentationtools.ReSTAutosummaryDirective(
                 options={
                     'nosignatures': True,
                     },
                 )
             for cls in sections[section_name]:
                 item = documentationtools.ReSTAutosummaryItem(
                     text=cls.__name__,
                     )
                 autosummary.append(item)
             document.append(autosummary)
     if functions:
         if classes:
             rule = documentationtools.ReSTHorizontalRule()
             document.append(rule)
         section_name = 'Functions'
         heading = documentationtools.ReSTHeading(
             level=3,
             text=section_name,
             )
         document.append(heading)
         toc = documentationtools.ReSTTOCDirective(
             options={
                 'hidden': True,
                 },
             )
         for function in functions:
             toc_item = documentationtools.ReSTTOCItem(
                 text=function.__name__,
                 )
             toc.append(toc_item)
         document.append(toc)
         autosummary = documentationtools.ReSTAutosummaryDirective(
             options={
                 'nosignatures': True,
                 },
             )
         for function in functions:
             item = documentationtools.ReSTAutosummaryItem(
                 text=function.__name__,
                 )
             autosummary.append(item)
         document.append(autosummary)
     return document