diff options
| author | hathach <[email protected]> | 2026-06-11 17:20:15 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2026-06-11 17:20:15 +0700 |
| commit | 5145b67f7946763ca04954f5494bfa88eec2acad (patch) | |
| tree | 9130540204c2404d532613adab01e88f4e918daa /docs/conf.py | |
| parent | f52d9c7b27dc0234fb4738762a8a6da01817e2bf (diff) | |
| parent | 0244a4f12e019406a4b73c75cd96f8efa096bbdc (diff) | |
Merge remote-tracking branch 'origin/master' into stm32c5
# Conflicts:
# README.rst
Diffstat (limited to 'docs/conf.py')
| -rwxr-xr-x | docs/conf.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/conf.py b/docs/conf.py index 9e9784fb7..86ddcf672 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -53,6 +53,25 @@ def preprocess_readme(): tgt = Path(__file__).parent.parent / "README_processed.rst" if src.exists(): content = src.read_text(encoding='utf-8') + # if the matching is inside a table, keep the table cell width by adding the same number of spaces in the end of the line + # match pattern: | ... `... <docs/...>`_ ... | + # change into: | ... `... <...>`_ ... | + def _rewrite_table_line(line): + if not (line.startswith('|') and line.rstrip().endswith('|')): + return line + + rewritten = re.sub(r"<docs/([^>]+)>", r"<\1>", line) + delta = len(line) - len(rewritten) - 1 # -1 for rst->html + + if delta > 0: + last_pipe = rewritten.rfind('|') + if last_pipe >= 0: + rewritten = rewritten[:last_pipe] + (' ' * delta) + rewritten[last_pipe:] + + return rewritten + + content = ''.join(_rewrite_table_line(line) for line in content.splitlines(keepends=True)) + content = re.sub(r"docs/", r"", content) content = re.sub(r"\.rst\b", r".html", content) if not content.endswith("\n"): |
