Update dependency mdformat-mkdocs to v4 (#15011)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[mdformat-mkdocs](https://redirect.github.com/kyleking/mdformat-mkdocs)
([changelog](https://redirect.github.com/kyleking/mdformat-mkdocs/releases))
| `==3.1.1` -> `==4.0.0` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/mdformat-mkdocs/4.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/mdformat-mkdocs/4.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/mdformat-mkdocs/3.1.1/4.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/mdformat-mkdocs/3.1.1/4.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>kyleking/mdformat-mkdocs (mdformat-mkdocs)</summary>

###
[`v4.0.0`](https://redirect.github.com/KyleKing/mdformat-mkdocs/releases/tag/v4.0.0)

[Compare
Source](https://redirect.github.com/kyleking/mdformat-mkdocs/compare/v3.1.1...v4.0.0)

#### What's Changed

- fix!: add newline after title for consistency with MKDocs style by
[@&#8203;KyleKing](https://redirect.github.com/KyleKing) in
[https://github.com/KyleKing/mdformat-mkdocs/pull/44](https://redirect.github.com/KyleKing/mdformat-mkdocs/pull/44)

**Full Changelog**:
https://github.com/KyleKing/mdformat-mkdocs/compare/v3.1.1...v4.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/astral-sh/ruff).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS41OC4xIiwidXBkYXRlZEluVmVyIjoiMzkuNTguMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiaW50ZXJuYWwiXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: Kyle King <KyleKing@users.noreply.github.com>
This commit is contained in:
renovate[bot] 2024-12-16 22:48:37 +05:30 committed by GitHub
parent 6a5eff6017
commit 50739f91dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 81 additions and 54 deletions

View file

@ -21,3 +21,11 @@ MD014: false
MD024:
# Allow when nested under different parents e.g. CHANGELOG.md
siblings_only: true
# MD046/code-block-style
#
# Ignore this because it conflicts with the code block style used in content
# tabs of mkdocs-material which is to add a blank line after the content title.
#
# Ref: https://github.com/astral-sh/ruff/pull/15011#issuecomment-2544790854
MD046: false

View file

@ -26,8 +26,7 @@ repos:
hooks:
- id: mdformat
additional_dependencies:
- mdformat-mkdocs<4.0.0
- mdformat-admon==2.0.6
- mdformat-mkdocs==4.0.0
- mdformat-footnote==0.1.1
exclude: |
(?x)^(

View file

@ -95,6 +95,7 @@ Similar to Ruff's CLI, the Ruff Language Server fully supports Jupyter Notebook
capabilities available to Python files.
!!! note
Unlike [`ruff-lsp`](https://github.com/astral-sh/ruff-lsp) and similar to the Ruff's CLI, the
native language server requires user to explicitly include the Jupyter Notebook files in the set
of files to lint and format. Refer to the [Jupyter Notebook discovery](https://docs.astral.sh/ruff/configuration/#jupyter-notebook-discovery)

View file

@ -22,6 +22,7 @@ The Ruff Language Server was available first in Ruff [v0.4.5](https://astral.sh/
in beta and stabilized in Ruff [v0.5.3](https://github.com/astral-sh/ruff/releases/tag/0.5.3).
!!! note
This is the documentation for Ruff's built-in language server written in Rust (`ruff server`).
If you are looking for the documentation for the `ruff-lsp` language server, please refer to the
[README](https://github.com/astral-sh/ruff-lsp) of the `ruff-lsp` repository.

View file

@ -4,6 +4,7 @@ While `ruff server` supports the same feature set as [`ruff-lsp`](https://github
`ruff server` may require changes to your Ruff or language server configuration.
!!! note
The [VS Code extension](https://github.com/astral-sh/ruff-vscode) settings include documentation to indicate which
settings are supported by `ruff server`. As such, this migration guide is primarily targeted at editors that lack
explicit documentation for `ruff server` settings, such as Helix or Neovim.
@ -20,6 +21,7 @@ Several `ruff-lsp` settings are not supported by `ruff server`. These are, as fo
- `path`
!!! note
Some of these settings, like `interpreter` and `path`, are still accepted by the VS Code
extension. `path`, in particular, can be used to specify a dedicated binary to use when
initializing `ruff server`. But the language server itself will no longer accept such settings.

View file

@ -23,6 +23,7 @@ behavior of the Ruff CLI.
**Example usage**:
=== "VS Code"
```json
{
"ruff.configuration": "~/path/to/ruff.toml"
@ -30,6 +31,7 @@ behavior of the Ruff CLI.
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -41,6 +43,7 @@ behavior of the Ruff CLI.
```
=== "Zed"
```json
{
"lsp": {
@ -72,6 +75,7 @@ configuration is prioritized over `ruff.toml` and `pyproject.toml` files.
**Example usage**:
=== "VS Code"
```json
{
"ruff.configurationPreference": "filesystemFirst"
@ -79,6 +83,7 @@ configuration is prioritized over `ruff.toml` and `pyproject.toml` files.
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -90,6 +95,7 @@ configuration is prioritized over `ruff.toml` and `pyproject.toml` files.
```
=== "Zed"
```json
{
"lsp": {
@ -116,6 +122,7 @@ documentation](https://docs.astral.sh/ruff/settings/#exclude) for more details.
**Example usage**:
=== "VS Code"
```json
{
"ruff.exclude": ["**/tests/**"]
@ -123,6 +130,7 @@ documentation](https://docs.astral.sh/ruff/settings/#exclude) for more details.
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -134,6 +142,7 @@ documentation](https://docs.astral.sh/ruff/settings/#exclude) for more details.
```
=== "Zed"
```json
{
"lsp": {
@ -159,6 +168,7 @@ The line length to use for the linter and formatter.
**Example usage**:
=== "VS Code"
```json
{
"ruff.lineLength": 100
@ -166,6 +176,7 @@ The line length to use for the linter and formatter.
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -177,6 +188,7 @@ The line length to use for the linter and formatter.
```
=== "Zed"
```json
{
"lsp": {
@ -202,6 +214,7 @@ Whether to register the server as capable of handling `source.fixAll` code actio
**Example usage**:
=== "VS Code"
```json
{
"ruff.fixAll": false
@ -209,6 +222,7 @@ Whether to register the server as capable of handling `source.fixAll` code actio
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -220,6 +234,7 @@ Whether to register the server as capable of handling `source.fixAll` code actio
```
=== "Zed"
```json
{
"lsp": {
@ -245,6 +260,7 @@ Whether to register the server as capable of handling `source.organizeImports` c
**Example usage**:
=== "VS Code"
```json
{
"ruff.organizeImports": false
@ -252,6 +268,7 @@ Whether to register the server as capable of handling `source.organizeImports` c
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -263,6 +280,7 @@ Whether to register the server as capable of handling `source.organizeImports` c
```
=== "Zed"
```json
{
"lsp": {
@ -290,6 +308,7 @@ Whether to show syntax error diagnostics.
**Example usage**:
=== "VS Code"
```json
{
"ruff.showSyntaxErrors": false
@ -297,6 +316,7 @@ Whether to show syntax error diagnostics.
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -308,6 +328,7 @@ Whether to show syntax error diagnostics.
```
=== "Zed"
```json
{
"lsp": {
@ -333,6 +354,7 @@ The log level to use for the server.
**Example usage**:
=== "VS Code"
```json
{
"ruff.logLevel": "debug"
@ -340,6 +362,7 @@ The log level to use for the server.
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -351,6 +374,7 @@ The log level to use for the server.
```
=== "Zed"
```json
{
"lsp": {
@ -378,6 +402,7 @@ If not set, logs will be written to stderr.
**Example usage**:
=== "VS Code"
```json
{
"ruff.logFile": "~/path/to/ruff.log"
@ -385,6 +410,7 @@ If not set, logs will be written to stderr.
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -396,6 +422,7 @@ If not set, logs will be written to stderr.
```
=== "Zed"
```json
{
"lsp": {
@ -425,6 +452,7 @@ Whether to display Quick Fix actions to disable rules via `noqa` suppression com
**Example usage**:
=== "VS Code"
```json
{
"ruff.codeAction.disableRuleComment.enable": false
@ -432,6 +460,7 @@ Whether to display Quick Fix actions to disable rules via `noqa` suppression com
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -447,6 +476,7 @@ Whether to display Quick Fix actions to disable rules via `noqa` suppression com
```
=== "Zed"
```json
{
"lsp": {
@ -476,6 +506,7 @@ Whether to display Quick Fix actions to autofix violations.
**Example usage**:
=== "VS Code"
```json
{
"ruff.codeAction.fixViolation.enable": false
@ -483,6 +514,7 @@ Whether to display Quick Fix actions to autofix violations.
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -498,6 +530,7 @@ Whether to display Quick Fix actions to autofix violations.
```
=== "Zed"
```json
{
"lsp": {
@ -531,6 +564,7 @@ Whether to enable linting. Set to `false` to use Ruff exclusively as a formatter
**Example usage**:
=== "VS Code"
```json
{
"ruff.lint.enable": false
@ -538,6 +572,7 @@ Whether to enable linting. Set to `false` to use Ruff exclusively as a formatter
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -551,6 +586,7 @@ Whether to enable linting. Set to `false` to use Ruff exclusively as a formatter
```
=== "Zed"
```json
{
"lsp": {
@ -580,6 +616,7 @@ Whether to enable Ruff's preview mode when linting.
**Example usage**:
=== "VS Code"
```json
{
"ruff.lint.preview": true
@ -587,6 +624,7 @@ Whether to enable Ruff's preview mode when linting.
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -600,6 +638,7 @@ Whether to enable Ruff's preview mode when linting.
```
=== "Zed"
```json
{
"lsp": {
@ -627,6 +666,7 @@ Rules to enable by default. See [the documentation](https://docs.astral.sh/ruff/
**Example usage**:
=== "VS Code"
```json
{
"ruff.lint.select": ["E", "F"]
@ -634,6 +674,7 @@ Rules to enable by default. See [the documentation](https://docs.astral.sh/ruff/
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -647,6 +688,7 @@ Rules to enable by default. See [the documentation](https://docs.astral.sh/ruff/
```
=== "Zed"
```json
{
"lsp": {
@ -674,6 +716,7 @@ Rules to enable in addition to those in [`lint.select`](#select).
**Example usage**:
=== "VS Code"
```json
{
"ruff.lint.extendSelect": ["W"]
@ -681,6 +724,7 @@ Rules to enable in addition to those in [`lint.select`](#select).
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -694,6 +738,7 @@ Rules to enable in addition to those in [`lint.select`](#select).
```
=== "Zed"
```json
{
"lsp": {
@ -721,6 +766,7 @@ Rules to disable by default. See [the documentation](https://docs.astral.sh/ruff
**Example usage**:
=== "VS Code"
```json
{
"ruff.lint.ignore": ["E4", "E7"]
@ -728,6 +774,7 @@ Rules to disable by default. See [the documentation](https://docs.astral.sh/ruff
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -741,6 +788,7 @@ Rules to disable by default. See [the documentation](https://docs.astral.sh/ruff
```
=== "Zed"
```json
{
"lsp": {
@ -768,6 +816,7 @@ Rules to disable in addition to those in [`lint.ignore`](#ignore).
**Example usage**:
=== "VS Code"
```json
{
"ruff.lint.extendIgnore": ["W1"]
@ -775,6 +824,7 @@ Rules to disable in addition to those in [`lint.ignore`](#ignore).
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -788,6 +838,7 @@ Rules to disable in addition to those in [`lint.ignore`](#ignore).
```
=== "Zed"
```json
{
"lsp": {
@ -819,6 +870,7 @@ Whether to enable Ruff's preview mode when formatting.
**Example usage**:
=== "VS Code"
```json
{
"ruff.format.preview": true
@ -826,6 +878,7 @@ Whether to enable Ruff's preview mode when formatting.
```
=== "Neovim"
```lua
require('lspconfig').ruff.setup {
init_options = {
@ -839,6 +892,7 @@ Whether to enable Ruff's preview mode when formatting.
```
=== "Zed"
```json
{
"lsp": {

View file

@ -8,11 +8,13 @@ regardless of editor, there are several settings which have changed or are no lo
the [migration guide](./migration.md) for more.
!!! note
The setup instructions provided below are on a best-effort basis. If you encounter any issues
while setting up the Ruff in an editor, please [open an issue](https://github.com/astral-sh/ruff/issues/new)
for assistance and help in improving this documentation.
!!! tip
Regardless of the editor, it is recommended to disable the older language server
([`ruff-lsp`](https://github.com/astral-sh/ruff-lsp)) to prevent any conflicts.
@ -45,6 +47,7 @@ require('lspconfig').ruff.setup({
```
!!! note
If the installed version of `nvim-lspconfig` includes the changes from
[neovim/nvim-lspconfig@`70d1c2c`](https://github.com/neovim/nvim-lspconfig/commit/70d1c2c31a88af4b36019dc1551be16bffb8f9db),
you will need to use Ruff version `0.5.3` or later.
@ -242,6 +245,7 @@ language-servers = ["ruff", "pylsp"]
```
!!! note
Support for multiple language servers for a language is only available in Helix version
[`23.10`](https://github.com/helix-editor/helix/blob/master/CHANGELOG.md#2310-2023-10-24) and later.
@ -287,6 +291,7 @@ logLevel = "debug"
You can also divert Ruff's logs to a separate file with the [`logFile`](./settings.md#logfile) setting.
!!! note
Setting `RUFF_TRACE=verbose` does not enable Helix's verbose mode by itself. You'll need to run
Helix with `-v` for verbose logging.
@ -313,6 +318,7 @@ See [LSP Client documentation](https://docs.kde.org/stable5/en/kate/kate/kate-ap
on how to configure the server from there.
!!! important
Kate's LSP Client plugin does not support multiple servers for the same language. As a
workaround, you can use the [`python-lsp-server`](https://github.com/python-lsp/python-lsp-server)
along with the [`python-lsp-ruff`](https://github.com/python-lsp/python-lsp-ruff) plugin to
@ -431,6 +437,7 @@ under the [`lsp.ruff.initialization_options.settings`](https://zed.dev/docs/conf
```
!!! note
Support for multiple formatters for a given language is only available in Zed version
`0.146.0` and later.
@ -438,6 +445,7 @@ You can configure Ruff to format Python code on-save by registering the Ruff for
and enabling the [`format_on_save`](https://zed.dev/docs/configuring-zed#format-on-save) setting:
=== "Zed 0.146.0+"
```json
{
"languages": {
@ -460,6 +468,7 @@ You can configure Ruff to fix lint violations and/or organize imports on-save by
`source.fixAll.ruff` and `source.organizeImports.ruff` code actions respectively:
=== "Zed 0.146.0+"
```json
{
"languages": {
@ -485,12 +494,14 @@ Taken together, you can configure Ruff to format, fix, and organize imports on-s
following `settings.json`:
!!! note
For this configuration, it is important to use the correct order of the code action and
formatter language server settings. The code actions should be defined before the formatter to
ensure that the formatter takes care of any remaining style issues after the code actions have
been applied.
=== "Zed 0.146.0+"
```json
{
"languages": {

View file

@ -4,8 +4,7 @@ mkdocs==1.6.1
mkdocs-material @ git+ssh://git@github.com/astral-sh/mkdocs-material-insiders.git@39da7a5e761410349e9a1b8abf593b0cdd5453ff
mkdocs-redirects==1.2.2
mdformat==0.7.19
mdformat-mkdocs==3.1.1
mdformat-admon==2.0.6
mdformat-mkdocs==4.0.0
# Using a commit from pygments main branch so we get
# https://github.com/pygments/pygments/pull/2773 before it's been released
pygments @ git+https://github.com/pygments/pygments.git@67b460fdde6d9a00342b5102b37b3a8399f0e8ef

View file

@ -4,8 +4,7 @@ mkdocs==1.6.1
mkdocs-material==9.5.38
mkdocs-redirects==1.2.2
mdformat==0.7.19
mdformat-mkdocs==3.1.1
mdformat-admon==2.0.6
mdformat-mkdocs==4.0.0
# Using a commit from pygments main branch so we get
# https://github.com/pygments/pygments/pull/2773 before it's been released
pygments @ git+https://github.com/pygments/pygments.git@67b460fdde6d9a00342b5102b37b3a8399f0e8ef

View file

@ -1,44 +0,0 @@
from __future__ import annotations
from typing import TYPE_CHECKING
import mdformat
if TYPE_CHECKING:
import argparse
from markdown_it import MarkdownIt
from mdformat.renderer import RenderContext, RenderTreeNode
class NoEscapeTextPlugin:
r"""Overrides the default text formatting behavior of mdformat.
By default mdformat will escape any markdown special character found in a
text block, e.g., <. Some of these characters are found in our
documentation, and when escaped (i.e. \<) will be rendered incorrectly by
mkdocs, i.e., the backslash will appear in the render. Because our only
purpose in using mdformat is to manage the line-breaks, it makes sense to
override its text formatting behavior.
"""
def __init__(self: NoEscapeTextPlugin) -> None:
self.POSTPROCESSORS = {"text": NoEscapeTextPlugin.text}
self.RENDERERS = {}
@staticmethod
def add_cli_options(parser: argparse.ArgumentParser) -> None:
pass
@staticmethod
def update_mdit(mdit: MarkdownIt) -> None:
pass
@staticmethod
def text(_text: str, node: RenderTreeNode, _context: RenderContext) -> str:
return node.content
def add_no_escape_text_plugin() -> None:
"""Add NoEscapeTextPlugin to the list of mdformat extensions."""
mdformat.plugins.PARSER_EXTENSIONS["no-escape-text"] = NoEscapeTextPlugin()

View file

@ -14,8 +14,6 @@ from typing import NamedTuple
import mdformat
import yaml
from _mdformat_utils import add_no_escape_text_plugin
class Section(NamedTuple):
"""A section to include in the MkDocs documentation."""
@ -229,12 +227,11 @@ def main() -> None:
f.write(clean_file_content(file_content, title))
add_no_escape_text_plugin()
for rule_doc in Path("docs/rules").glob("*.md"):
# Format rules docs. This has to be completed before adding the meta description
# otherwise the meta description will be formatted in a way that mkdocs does not
# support.
mdformat.file(rule_doc, extensions=["mkdocs", "admon", "no-escape-text"])
mdformat.file(rule_doc, extensions=["mkdocs"])
generate_rule_metadata(rule_doc)