Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kemingy opened this issue Dec 14, 2022 · 1 comment
Open

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

kemingy opened this issue Dec 14, 2022 · 1 comment

Comments

@kemingy
Copy link

kemingy commented Dec 14, 2022

Environment

  • Pydoc-Markdown Version: v4.6.4
  • Python Version: v3.10.5
  • Operating System: Ubuntu 22.04

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

def dotted_name(obj: docspec.ApiObject) -> str:
return ".".join(x.name for x in obj.path)

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
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants