pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

Show short submodule names in TOC

Open jackblk opened this issue 5 years ago • 2 comments

Sorry for asking a very basic question but I've done some research & no result.

Here's my folder structure: main-long-name-folder |--modules |----|--helper.py |--test.py

I'm using some functions in helper.py like helper.action1(). I use pdoc to generate HTML. Problem is, after generating successfully, the sub-modules in left sidebar has long package prefix name, for example: main-long-name-folder.modules.

I figure that I can change the name by changing the folder name main-long-name-folder to main then run the pdoc again, but it is not a good way to do because the repo name is fixed, I don't want to change folder name.

Do we have anyway to re-define the package name or changing refname of package to make it a lot shorter?

Thanks a lot.

jackblk avatar Sep 30 '20 08:09 jackblk

Docs hierarchy follows module hierarchy

This is one of the selling points, so a strict, fully-functional module refname overriding is out of the question.

You could override html.mako template and adjust how TOC modules are shown: https://github.com/pdoc3/pdoc/blob/d8b9dbc2a128099e89a9d7859720dac56d574094/pdoc/templates/html.mako#L313-L321

E.g. by using:

${ link(m, name=m.name.split('.')[-1]) }

kernc avatar Oct 01 '20 22:10 kernc

Since my "package" name does not mean anything, it's just a repo so I decided to remove name completely in both navbar & contents inside. Here's my implementation:

${link(m, name=m.name.split('.', 1)[1])}

Thanks a lot for your help, you're brilliant :).

jackblk avatar Oct 02 '20 04:10 jackblk