Example #1
0
 def _build_bases_section(self):
     from abjad.tools import documentationtools
     pieces = []
     pieces.append(documentationtools.ReSTHeading(
         level=3,
         text='Bases',
     ))
     mro = inspect.getmro(self.subject)[1:]
     for cls in mro:
         packagesystem_path = '.'.join((cls.__module__, cls.__name__))
         stripped_packagesystem_path = self._shrink_module_name(
             packagesystem_path)
         if packagesystem_path.startswith('__builtin__'):
             packagesystem_path = \
                 packagesystem_path.partition('__builtin__.')[-1]
         text = '- :py:class:`{} <{}>`'.format(
             stripped_packagesystem_path,
             packagesystem_path,
         )
         paragraph = documentationtools.ReSTParagraph(
             text=text,
             wrap=False,
         )
         pieces.append(paragraph)
     return pieces
Example #2
0
 def _build_bases_section(self, cls):
     from abjad.tools import documentationtools
     result = []
     result.append(documentationtools.ReSTHeading(
         level=3,
         text='Bases',
         ))
     mro = inspect.getmro(cls)[1:]
     for cls in mro:
         parts = cls.__module__.split('.') + [cls.__name__]
         while 1 < len(parts) and parts[-1] == parts[-2]:
             parts.pop()
         packagesystem_path = '.'.join(parts)
         text = '- :py:class:`{}`'.format(packagesystem_path)
         paragraph = documentationtools.ReSTParagraph(
             text=text,
             wrap=False,
             )
         result.append(paragraph)
     return result
Example #3
0
 def _build_enumeration_section(self, cls):
     from abjad.tools import documentationtools
     result = []
     if not issubclass(cls, enum.Enum):
         return result
     items = sorted(cls, key=lambda x: x.name)
     if items:
         result.append(documentationtools.ReSTHeading(
             level=3,
             text='Enumeration Items',
             ))
         for item in items:
             name = item.name
             value = item.value
             line = '- `{}`: {}'.format(name, value)
             paragraph = documentationtools.ReSTParagraph(
                 text=line,
                 wrap=False,
                 )
             result.append(paragraph)
     return result