docs: color output for docs (#2407)
* docs: color output for docs Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: use asdf (python-build) * docs: try to fix colors Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update .pre-commit-config.yaml * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
pre-commit-ci[bot]
parent
2346c5f6e0
commit
c90accef51
@@ -87,7 +87,8 @@ repos:
|
|||||||
- id: check-github-actions
|
- id: check-github-actions
|
||||||
- id: check-github-workflows
|
- id: check-github-workflows
|
||||||
- id: check-gitlab-ci
|
- id: check-gitlab-ci
|
||||||
- id: check-readthedocs
|
# Disabled due to schema issue for now:
|
||||||
|
# - id: check-readthedocs
|
||||||
- id: check-travis
|
- id: check-travis
|
||||||
- id: check-jsonschema
|
- id: check-jsonschema
|
||||||
name: Check projects
|
name: Check projects
|
||||||
|
|||||||
+3
-3
@@ -3,10 +3,10 @@
|
|||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
build:
|
build:
|
||||||
os: ubuntu-22.04
|
os: ubuntu-24.04
|
||||||
tools:
|
|
||||||
python: "3.12"
|
|
||||||
commands:
|
commands:
|
||||||
|
- asdf install python 3.14-dev
|
||||||
|
- asdf global python 3.14-dev
|
||||||
- asdf plugin add uv
|
- asdf plugin add uv
|
||||||
- asdf install uv latest
|
- asdf install uv latest
|
||||||
- asdf global uv latest
|
- asdf global uv latest
|
||||||
|
|||||||
+15
-1
@@ -1,8 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sysconfig
|
import sysconfig
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
import rich.console
|
||||||
|
import rich.text
|
||||||
|
|
||||||
|
|
||||||
def define_env(env: Any) -> None:
|
def define_env(env: Any) -> None:
|
||||||
"Hook function for mkdocs-macros"
|
"Hook function for mkdocs-macros"
|
||||||
@@ -12,5 +16,15 @@ def define_env(env: Any) -> None:
|
|||||||
"Run a subprocess and return the stdout"
|
"Run a subprocess and return the stdout"
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
scripts = sysconfig.get_path("scripts")
|
scripts = sysconfig.get_path("scripts")
|
||||||
|
env.pop("NO_COLOR", None)
|
||||||
env["PATH"] = f"{scripts}{os.pathsep}{env.get('PATH', '')}"
|
env["PATH"] = f"{scripts}{os.pathsep}{env.get('PATH', '')}"
|
||||||
return subprocess.run(args, check=True, capture_output=True, text=True, env=env).stdout
|
env["PYTHON_COLORS"] = "1"
|
||||||
|
output = subprocess.run(args, check=True, capture_output=True, text=True, env=env).stdout
|
||||||
|
rich_text = rich.text.Text.from_ansi(output)
|
||||||
|
console = rich.console.Console(record=True, force_terminal=True)
|
||||||
|
console.print(rich_text)
|
||||||
|
page = console.export_html(inline_styles=True)
|
||||||
|
result = re.search(r"<body.*?>(.*?)</body>", page, re.DOTALL | re.IGNORECASE)
|
||||||
|
assert result
|
||||||
|
txt = result.group(1).strip()
|
||||||
|
return txt.replace("code ", 'code class="nohighlight" ')
|
||||||
|
|||||||
@@ -1714,9 +1714,7 @@ Platform-specific environment variables are also available:<br/>
|
|||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
```text
|
|
||||||
« subprocess_run("cibuildwheel", "--help") »
|
« subprocess_run("cibuildwheel", "--help") »
|
||||||
```
|
|
||||||
|
|
||||||
### Return codes
|
### Return codes
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -173,7 +173,7 @@ def bump_version(session: nox.Session) -> None:
|
|||||||
session.install_and_run_script("bin/bump_version.py")
|
session.install_and_run_script("bin/bump_version.py")
|
||||||
|
|
||||||
|
|
||||||
@nox.session(default=False, python="3.12")
|
@nox.session(default=False)
|
||||||
def docs(session: nox.Session) -> None:
|
def docs(session: nox.Session) -> None:
|
||||||
"""
|
"""
|
||||||
Build the docs. Will serve unless --non-interactive
|
Build the docs. Will serve unless --non-interactive
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ docs = [
|
|||||||
"mkdocs-macros-plugin",
|
"mkdocs-macros-plugin",
|
||||||
"mkdocs==1.6.1",
|
"mkdocs==1.6.1",
|
||||||
"pymdown-extensions",
|
"pymdown-extensions",
|
||||||
|
"rich",
|
||||||
]
|
]
|
||||||
test = [
|
test = [
|
||||||
"build",
|
"build",
|
||||||
|
|||||||
Reference in New Issue
Block a user