Skip to content

Parser is unset when a static analysis cannot find a docstring, but dynamic can #364

Open
@machow

Description

@machow

From this ibis comment (cc @cpcloud , @jcrist): https://github.com/ibis-project/ibis/pull/10079/files/152f15265038453bd34a4742a1c34ac913ced186#r1752391475

When a user dynamically loads a docstring, quartodoc does the following:

  • loads object statically (as griffe data)
  • loads object dynamically (as an import)
  • replaces the static object's docstring with the dynamic one

quartodoc tries to preserve the parser settings when doing this, by copying the settings from the static docstring. However, when there's no static docstring, it accidentally sets things like parser to None. This means that tools like griffe don't know it's parsing a numpy docstring.

See

  • old = obj.docstring
    new = dc.Docstring(
    value=f.__doc__,
    lineno=getattr(old, "lineno", None),
    endlineno=getattr(old, "endlineno", None),
    parent=getattr(old, "parent", None),
    parser=getattr(old, "parser", None),
    parser_options=getattr(old, "parser_options", None),
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions