NiklasRosenstein / pydoc-markdown

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

`header_level_by_type` renderer setting doesn't take effect in v4.6.0 #248

Closed kellyjonbrazil closed 2 years ago

kellyjonbrazil commented 2 years ago

Environment

Describe the bug The header_level_by_type renderer setting doesn't seem to be taking effect anymore in v4.6.0. It was working in 4.5.0, but in 4.6.0 the heading sizes are going back to defaults even when header_level_by_type is set. I also tried adding the use_fixed_header_levels option, but that didn't seem to help. Here is my configuration (it was working in 4.5.0 without use_fixed_header_levels):

{
    "processors": [
        {
            "type": "filter"
        },
        {
            "type": "pydocmd"
        }
    ],
    "renderer": {
        "type": "markdown",
        "use_fixed_header_levels": true,
        "header_level_by_type": {
            "Module": 1,
            "Class": 3,
            "Method": 3,
            "Function": 3,
            "Data": 3
        }
    }
}

Expected behavior

The markdown heading sizes should conform to the ones specified in the configuration.

kellyjonbrazil commented 2 years ago

Some more detail: I'm trying to keep the headings at level 3, e.g.:

### function

When I set use_fixed_header_levels to true the header levels go to 4 for the most part. When I set it to false, they go down to 2.

NiklasRosenstein commented 2 years ago

Hey @kellyjonbrazil , thanks for reporting the issue. After taking a quick look, maybe I have messed up here a bit:

https://github.com/NiklasRosenstein/pydoc-markdown/blob/8c69a74a8e3c6412c3461833573f74babc30a81e/src/pydoc_markdown/contrib/renderers/markdown.py#L248-L257

Can you try "Variable": 3 instead of "Data": 3? And I'll look to fix this piece of code that's supposed to keep the name change backwards compatible.

kellyjonbrazil commented 2 years ago

Thanks for checking - that didn't seem to help. The one that is most prevalent in my docs is the Function header. I don't think I have any Data or Variable headers, but I put it in my config just to make it all consistent if I do in the future.

NiklasRosenstein commented 2 years ago

You're right, there's actually a second issue in the same piece of code. 😢

Can you try 4.6.1 ?

kellyjonbrazil commented 2 years ago

Beautiful, that worked - thanks!