mitmproxy / pdoc

API Documentation for Python Projects
https://pdoc.dev
MIT No Attribution
1.89k stars 189 forks source link

emphasize the `@deprecated` decorator #668

Open DetachHead opened 5 months ago

DetachHead commented 5 months ago

Problem Description

python now has a @deprecated decorator: https://peps.python.org/pep-0702/

in pdoc it's just treated like a normal decorator and is quite easy to miss: image

Proposal

display the deprecated message as a warning, something like this:

image

Additional context

the decorator isn't coming to python until 3.13, but it can currently be used older python versions by importing it from typing_extensions. vscode already supports it too

mhils commented 5 months ago

I like the idea, but implementation-wise I don't particularly like decorators having a magic effect on docstrings. One viable workaround here could be to add the decorator name to the CSS class and then apply a CSS filter like so:

section:has(.decorator-deprecated) {
    filter: grayscale(1) opacity(0.8);
}

image

This is just one idea - we could also do a CSS thing that highights the @deprecated annotation like so:

.decorator-deprecated {
    background: #ffe91d78;
    margin-left: -15px;
    padding-left: 15px;
    margin-right: -5px;
    padding-right: 5px;
}

image

Maybe that's better because it's less likely to run into accessibility issues. :)