コード例 #1
0
ファイル: epydoc2stan.py プロジェクト: Kalebu/pydoctor
def reportErrors(obj: model.Documentable, errs: Sequence[ParseError]) -> None:
    if errs and obj.fullName() not in obj.system.docstring_syntax_errors:
        obj.system.docstring_syntax_errors.add(obj.fullName())
        for err in errs:
            obj.report('bad docstring: ' + err.descr(),
                       lineno_offset=(err.linenum() or 1) - 1,
                       section='docstring')
コード例 #2
0
ファイル: util.py プロジェクト: Kalebu/pydoctor
def taglink(o: model.Documentable, label: Optional[str] = None) -> Tag:
    if not o.isVisible:
        o.system.msg("html", "don't link to %s" % o.fullName())
    if label is None:
        label = o.fullName()
    # Create a link to the object, with a "data-type" attribute which says what
    # kind of object it is (class, etc). This helps doc2dash figure out what it
    # is.
    ret: Tag = tags.a(href=o.url, class_="code", **{"data-type":
                                                    o.kind})(label)
    return ret
コード例 #3
0
ファイル: _pydoctor.py プロジェクト: rr-/docstring_parser
 def privacyClass(self, documentable: Documentable) -> PrivacyClass:
     """Report the privacy level for an object. Hide the module
     'docstring_parser.tests'.
     """
     if documentable.fullName().startswith("docstring_parser.tests"):
         return PrivacyClass.HIDDEN
     return super().privacyClass(documentable)
コード例 #4
0
ファイル: epydoc2stan.py プロジェクト: igraph/pydoctor
def taglink(o: model.Documentable,
            page_url: str,
            label: Optional[str] = None) -> Tag:
    if not o.isVisible:
        o.system.msg("html", "don't link to %s" % o.fullName())

    if label is None:
        label = o.fullName()

    url = o.url
    if url.startswith(page_url + '#'):
        # When linking to an item on the same page, omit the path.
        # Besides shortening the HTML, this also avoids the page being reloaded
        # if the query string is non-empty.
        url = url[len(page_url):]

    ret: Tag = tags.a(label, href=url)
    return ret
コード例 #5
0
def objects_order(o: model.Documentable) -> Tuple[int, int, str]:
    """
    Function to use as the value of standard library's L{sorted} function C{key} argument
    such that the objects are sorted by: Privacy, Kind and Name.

    Example::

        children = sorted((o for o in ob.contents.values() if o.isVisible),
                      key=objects_order)
    """
    return (-o.privacyClass.value, -o.kind.value if o.kind else 0,
            o.fullName().lower())
コード例 #6
0
ファイル: sphinx.py プロジェクト: graingert/pydoctor
    def _generateLine(self, obj: Documentable) -> str:
        """
        Return inventory line for object.

        name domain_name:type priority URL display_name

        Domain name is always: py
        Priority is always: -1
        Display name is always: -
        """
        # Avoid circular import.
        from pydoctor import model

        full_name = obj.fullName()

        if obj.documentation_location is model.DocLocation.OWN_PAGE:
            url = obj.fullName() + '.html'
        else:
            url = obj.parent.fullName() + '.html#' + obj.name

        display = '-'
        if isinstance(obj, (model.Package, model.Module)):
            domainname = 'module'
        elif isinstance(obj, model.Class):
            domainname = 'class'
        elif isinstance(obj, model.Function):
            if obj.kind == 'Function':
                domainname = 'function'
            else:
                domainname = 'method'
        elif isinstance(obj, model.Attribute):
            domainname = 'attribute'
        else:
            domainname = 'obj'
            self.error('sphinx', "Unknown type %r for %s." % (
                type(obj),
                full_name,
            ))

        return f'{full_name} py:{domainname} -1 {url} {display}\n'
コード例 #7
0
ファイル: summary.py プロジェクト: tristanlatr/pydoctor
def _lckey(x: model.Documentable) -> Tuple[str, str]:
    return (x.fullName().lower(), x.fullName())
コード例 #8
0
ファイル: summary.py プロジェクト: tristanlatr/pydoctor
 def fullName(obj: model.Documentable) -> str:
     return obj.fullName()