-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Some docs not rendering properly #10427
Comments
Thanks for flagging this! |
Ok so there are two issues at play here.
will not be rendered as lists by python-mardown (Python-Markdown/markdown#1442), which is what mkdocs uses to transcompile the mardown to html. Instead a newline needs to be added between the sentence and items.
Annoyingly, this is different from the behavior of many other markdown processors (including the one used on github) so most people will not be expecting this.
|
Regarding issue 1, it is a fairly easy fix to change the comments in the code docs, but might be difficult to ensure all of them are fixed. Secondly, because the behavior is so different to what people are used to I feel something should be done to prevent this in the future. |
Regarding issue 2, the doc prepossor could be expanded to accept more patterns, but it depends how frequent this type of links will appear outside the |
Yeah this is a little annoying, maybe we can run our markdown formatter on the generated documentation? I wonder if it adds spacing. In the meantime, it seems like adding the missing spaces makes sense. I'm not sure about the automatic linking, @charliermarsh do you have context on the original intent of limiting the scope? |
I think it’s just because the original intent was for that to support the Options section which always has that format. We can expand the scope a bit though. |
Are you already running a markdown formatter in the project? |
If not we could try running https://github.com/executablebooks/mdformat which seems to do the trick. |
For the option processing we could match this regex |
We use a couple https://github.com/astral-sh/ruff/blob/main/.pre-commit-config.yaml#L20-L41 It might require a tweak to run them on the generated documentation |
@zanieb I started implementing a check using mdformat, but as it is right now pretty much every doc has multiple violations (mostly missing or extra newlines). For example:
So if we go the route of enforcing markdown style on rule docs it will require a lot of edits. Alternatively, if we only care about enforcing a line break around lists, this could be done with a simple python check. Something like: |
Another option would be to format the docs as part of the generation process |
@zanieb what do you think between these three options? Remember the goal is just to ensure that lists get rendered properly.
|
I honestly was imagining (3) but we'd probably want to run that check on pull requests too in case someone breaks the formatter in which case it would require manual intervention. |
What do you mean "breaks the formatter", like raise an unexpected error? |
Yeah, idk if something goes wrong like it formats and can't render or the formatter errors. |
So adding it as part of generate_mkdocs.py would make sense, since that gets run for every PR. |
Ya I was gonna work on that next. The problem is that when someone attempts a reference to a setting, but doesn't make an options section with that setting, the reference doesn't get linked. My approach is gonna be to check any reference which matches the pattern [ |
#10484) ## Summary The purpose of this change is mainly to address one of the issues outlined in #10427. Namely, some lists in the docs were not rendering properly when preceded by a text block without a newline character. This PR adds `mdformat` as a final step to the rule documentation script, so that any missing newlines will be added. NB: The default behavior of `mdformat` is to escape markdown special characters found in text such as `<`. This resulted in some misformatted docs. To address this I implemented an ad-hoc mdformat plugin to override the behavior. This may be considered a bit 'hacky', but I think it's a good solution. Nevertheless, if someone has a better idea, let me know. ## Test Plan This change is hard to test systematically, however, I tried my best to look at the before and after diffs to ensure no unwanted changes were made to the docs.
Thanks, I fixed those specific docs here: #10498 |
What are your thoughts on my comment though. Should we allow linking settings without an options section? If not should we flag attempts to do so? |
Honestly, I'm fine with either. We should at least flag references that are missing from the |
Ok I will work on that |
## Summary Some contributors have referenced settings in their documentation without adding the settings to an options section, this has lead to some rendering issues (#10427). This PR addresses this looking for potential inline links to settings, cross-checking them with the options sections, and then linking them anyway if they are not found. Resolves #10427. ## Test Plan Manually verified that the correct modifications were made and no docs were broken.
https://docs.astral.sh/ruff/rules/too-many-blank-lines/ (among others) is not rendering properly, even though the markdown seems fine.
The list is not rendered as a bullet list.
The links to settings do not link.
The text was updated successfully, but these errors were encountered: