pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

Way to explicitly shorten identifier in a docstring

Open earshinov opened this issue 9 months ago • 1 comments

Problem Description

In a docstring for earhinov_utils.kedro.datasets.gsheets.GoogleSheetsDataset, I would like to mention earshinov_utils.kedro.datasets.pandas.PandasWrapperDataset, and:

  • I would like the latter to be turned into a hyperlink
  • I would like the text of the hyperlink to be PandasWrapperDataset instead of earshinov_utils.kedro.datasets.pandas.PandasWrapperDataset, as
    • I assume that by this moment the user is already familiar with PandasWrapperDataset
    • even if they are not, they can follow the hyperlink

There seems to be no way to achieve this currently with pdoc. A couple of things that I tried:

  • PandasWrapperDataset (in backticks, which I cannot use here) is naturally not hyperlinked
  • [PandasWrapperDataset](earshinov_utils.kedro.datasets.pandas.PandasWrapperDataset) results in a broken markup (even without backticks)
  • [PandasWrapperDataset][earshinov_py_utils.kedro.datasets.pandas.PandasWrapperDataset] is not recognized

Proposal

I assume, mkdocs, or rather mkdocstrings, or maybe the underlying Griffe, do recognize this syntax:

[PandasWrapperDataset][earshinov_py_utils.kedro.datasets.pandas.PandasWrapperDataset]

(See, for example, the description of mkdocstrings-python-xref)

With pdoc being the best API doc generator for Python, it would be nice if it had this feature as well :)

I would also appreciate if the first bracket supported arbitrary syntax, particularly backticks.

Alternatives

Keep using the full identifier (earshinov_py_utils.kedro.datasets.pandas.PandasWrapperDataset), which makes the rendered documentation harder to read and less visually appealing due to messy line breaks.

Additional context

Thank you for a wonderful tool. Discovered it just this week, and enjoyed the fact that it works out of the box

earshinov avatar Mar 13 '25 11:03 earshinov

Happy to accept a PR that makes [PandasWrapperDataset][earshinov_py_utils.kedro.datasets.pandas.PandasWrapperDataset] work!

mhils avatar Mar 13 '25 14:03 mhils