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

Escaping characters in docstring raises DOC103 #73

Closed
haakonvt opened this issue Aug 21, 2023 · 2 comments · Fixed by #74
Closed

Escaping characters in docstring raises DOC103 #73

haakonvt opened this issue Aug 21, 2023 · 2 comments · Fixed by #74

Comments

@haakonvt
Copy link

haakonvt commented Aug 21, 2023

This is more a question than an issue (I'm sorry for opening my third issue in a week's time...).

I am on the brink of adding pydoclint to my company's codebase (started at 1000 issues.... now down to 1), but the only way I'm able to is by excluding the file via pre-commit.

I have the following class:

class Foo:
    r"""Description

    Args:
        with\_ (dict): Description
        select (str): Description
    """
    def __init__(self, with_: dict, select: str):
        ...

pydoclint imo correctly raises:

    8: DOC103: Method `Foo.__init__`: Docstring arguments are different from function arguments.
(Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). 
Arguments in the function signature but not in the docstring: [with_: dict]. Arguments in the docstring but 
not in the function signature: [with\_: dict].

If I try to remove the \ before the underscore, sphinx complains:

$ .Foo:7: ERROR: Unknown target name: "with".

...and the documentation shows with instead of with_.

Do you have a suggested approach here (outside excluding the entire file?) 🙏

@jsh9
Copy link
Owner

jsh9 commented Aug 22, 2023

Hi @haakonvt , thanks for raising this issue!

I didn't know that Sphinx requires escaping underscores. And interestingly, only 1 or 2 trailing underscores need to be escaped. 3 or more trailing underscores and preceding underscores don't seem to need to be escaped.

I've pushed a fix and it will be published as v0.2.2.

@jsh9 jsh9 closed this as completed in #74 Aug 22, 2023
@haakonvt
Copy link
Author

That's great! Thanks a lot (again) @jsh9 🙏 👏

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

Successfully merging a pull request may close this issue.

2 participants