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

namespell: Ignore text inside code blocks #14

Merged
merged 7 commits into from
Oct 22, 2024
Merged

Conversation

PLangowski
Copy link
Contributor

No description provided.

@PLangowski PLangowski marked this pull request as draft September 13, 2024 07:54
@PLangowski PLangowski linked an issue Sep 13, 2024 that may be closed by this pull request
@PLangowski PLangowski marked this pull request as ready for review September 13, 2024 08:07
@PLangowski
Copy link
Contributor Author

The changes have been tested on meta-dts

Copy link
Contributor

@m-iwanicki m-iwanicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Add `inline code`, script still fails in e.g. Zarhus docs
  2. Make it configurable (via e.g. --ignore-codeblocks) e.g. (not tested)
parser.add_argument(
        "-i",
        "--ignore-codeblocks",
        action="store_true",
        default=False,
        help="Ignore codeblocks",
    )

hooks/namespell.py Outdated Show resolved Hide resolved
@m-iwanicki
Copy link
Contributor

m-iwanicki commented Sep 17, 2024

I think you need some test files to make sure namespell works as intended and there are no regressions.

Not sure if you can disable rule on next line as it's usually done in other checkers e.g.

(...)
# namespell:disable
disable only this line
(...)

This file should probably show no errors:
no_errors.md

Currently:

  • names in single backticks (markdown code) e.g. `zarhus` is treated as error: line 1, 3

  • not sure if comments should be ignored or not (maybe configurable?). But currently I see that they are unless they are inline comments, e.g. this <!-- zarhus --> isn't ignored: line 3

  • line 19: treats ``` not at the beginning as closing tag e.g.:

    ```
    ignore this zarhus ```
    this zarhus should also be ignored but isn't
    ```
    

    Not only that but it then treats the first zarhus as error not only second

@PLangowski
Copy link
Contributor Author

@m-iwanicki code blocks shouldn't contain triple backticks, that's why i didn't add support for this. If you delete them form line 19, then namespell only shows errors with inline code.

@m-iwanicki
Copy link
Contributor

@PLangowski Are you sure?

```

Or

```
````

Or

-```

Each block is formatted and displayed correctly by GitHub or other markdown parsers. Your code will silently fail in this case and it'd be very hard to know it isn't working correctly.
I'm saying all this because I'd want this hook to be more widely used but in current state it faces opposition to wider adoption.

@PLangowski
Copy link
Contributor Author

PLangowski commented Sep 30, 2024

For now I was able to implement ignoring inline code/comments 48dffcb

@PLangowski
Copy link
Contributor Author

@m-iwanicki The cases you've presented are quite difficult to implement, and aren't that widely used. I agree that they're valid, but maybe we could track them in another issue and try to implement them in the future?

@m-iwanicki
Copy link
Contributor

@PLangowski I guess that's ok.

@PLangowski
Copy link
Contributor Author

Can we merge this then?

@m-iwanicki
Copy link
Contributor

Looks ok, but fix pre-commit failures before merging

Signed-off-by: Pawel Langowski <[email protected]>
@PLangowski
Copy link
Contributor Author

@m-iwanicki done

@PLangowski PLangowski merged commit 7dacedb into main Oct 22, 2024
1 check passed
@PLangowski PLangowski deleted the ignore_codeblocks branch October 22, 2024 12:16
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 this pull request may close these issues.

In markdown, we should ignore content in the code blocks
2 participants