NiklasRosenstein / pydoc-markdown

Create Python API documentation in Markdown format.
http://niklasrosenstein.github.io/pydoc-markdown/
Other
449 stars 104 forks source link

`add_full_prefix` will also add the `__init__` path to its title #276

Open kemingy opened 1 year ago

kemingy commented 1 year ago

Environment

Describe the bug

When using the MarkdownRenderer with add_full_prefix enabled, if there are functions defined in the __init__.py file, the prefix will also contain __init__.. Refer to https://github.com/NiklasRosenstein/pydoc-markdown/blob/3aa2fa94f514ee827992e4145a23e1260b5a4efd/src/pydoc_markdown/contrib/renderers/markdown.py#L47-L48

Expected behavior

I think __init__ should be ignored in the dotted_name function. Let's say you have a demo function in my_package/__init__.py, its title should be my_package.demo instead of my_package.__init__.demo.

NiklasRosenstein commented 1 year ago

Hey @kemingy , unfortunately I could not replicate the behaviour.

diff --git a/examples/mkdocs/pyproject.toml b/examples/mkdocs/pyproject.toml
index 5291e54..6dce064 100644
--- a/examples/mkdocs/pyproject.toml
+++ b/examples/mkdocs/pyproject.toml
@@ -5,6 +5,9 @@ search_path = [ "../src" ]
 [tool.pydoc-markdown.renderer]
 type = "mkdocs"

+[tool.pydoc-markdown.renderer.markdown]
+add_full_prefix = true
+
 [[tool.pydoc-markdown.renderer.pages]]
 title = "API Documentation"
 name = "index"
diff --git a/examples/src/school/__init__.py b/examples/src/school/__init__.py
index 9818a23..8f7fe4f 100644
--- a/examples/src/school/__init__.py
+++ b/examples/src/school/__init__.py
@@ -8,3 +8,8 @@ from ._pupil import Pupil
 from ._teacher import Teacher
 from ._school import School
 from ._api._v1 import SchoolApiV1
+
+
+def demo():
+    "Hello"
+    pass
$ cd examples/mkdocs
$ pydoc-markdown -so

image

Can you still reproduce the issue?