Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Default role does not detect default roles starting with a single quote #40

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

Closed
JulienPalard opened this issue Jun 28, 2022 · 3 comments
Closed

Comments

@JulienPalard
Copy link
Collaborator

For example in:

Lines containing `'RESTART'` mean that the user execution process has been\n

The default_role_re (currently re.compile('(^| )`\\w([^`]*?\\w)?`($| )')) won't catch it due to the \W not matching the quote.

@ezio-melotti
Copy link
Collaborator

The regex also doesn't detect default roles that are followed by a ), ,, ., etc., or preceded by a ( and similar characters -- it only detects them if they are preceded/followed by a space or if they are at the beginning/end of the line:

$ echo 'This is not detected: (`foo`)' >> buggy.rst; sphinx-lint --enable default-role buggy.rst
No problems found.
$ echo 'This is detected: ( `foo` )' >> buggy.rst; sphinx-lint --enable default-role buggy.rst
buggy.rst:2: default role used (hint: for inline literals, use double backticks) (default-role)
$ echo 'This is not detected: `foo`, `bar`.' >> buggy.rst; sphinx-lint --enable default-role buggy.rst
buggy.rst:2: default role used (hint: for inline literals, use double backticks) (default-role)
$ echo 'This is detected: `foo` , `bar`.' >> buggy.rst; sphinx-lint --enable default-role buggy.rst
buggy.rst:2: default role used (hint: for inline literals, use double backticks) (default-role)
buggy.rst:4: default role used (hint: for inline literals, use double backticks) (default-role)
$ cat buggy.rst 
This is not detected: (`foo`)
This is detected: ( `foo` )
This is not detected: `foo`, `bar`.
This is detected: `foo` , `bar`.

@ezio-melotti
Copy link
Collaborator

Another real world example I met today:

$ echo 'The only supported backend is `"perf"`.' > buggy.rst
$ sphinx-lint --enable default-role buggy.rst 
No problems found.
$ echo 'The only supported backend is `perf`.' >> buggy.rst
$ sphinx-lint --enable default-role buggy.rst 
No problems found.

@ezio-melotti
Copy link
Collaborator

Another one:

$ echo 'Assignment expressions using the walrus operator `:=` assign a variable' > buggy.rst
$ sphinx-lint --enable default-role buggy.rst 
No problems found.

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

No branches or pull requests

2 participants