mirror of
https://github.com/clang-retro/mfc.git
synced 2026-11-28 13:19:26 -08:00
Add a documentation site, published on GitHub Pages
mkdocs.yml builds a Material for MkDocs site from docs/. Its pages take their text from the README and the other Markdown files of the repository: .docs/hooks.py includes them by section and points their links at the right page, or at the file on GitHub, so the README stays the one place to write things down. .docs/base.yml holds the look that every clang-retro site shares. .github/workflows/docs.yml builds the site with --strict for every pull request and push, and publishes it from the default branch once GitHub Pages is set to deploy from GitHub Actions. Signed-off-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRTLG3jxEW8av9GuXpG
This commit is contained in:
17 files changed
+466
No files matched your search
Binary file not shown.
@@ -0,0 +1,85 @@
|
||||
# Settings shared by every clang-retro documentation site. Each repository's
|
||||
# mkdocs.yml inherits them (INHERIT) and adds its name, pages and links.
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
copyright: Copyright © clang-retro contributors · AGPL-3.0-only
|
||||
|
||||
theme:
|
||||
name: material
|
||||
logo: assets/logo.png
|
||||
favicon: assets/logo.png
|
||||
font:
|
||||
text: IBM Plex Sans
|
||||
code: IBM Plex Mono
|
||||
icon:
|
||||
repo: fontawesome/brands/github
|
||||
palette:
|
||||
- media: "(prefers-color-scheme)"
|
||||
toggle:
|
||||
icon: material/brightness-auto
|
||||
name: Light mode
|
||||
- media: "(prefers-color-scheme: light)"
|
||||
scheme: default
|
||||
primary: custom
|
||||
accent: custom
|
||||
toggle:
|
||||
icon: material/brightness-7
|
||||
name: Dark mode
|
||||
- media: "(prefers-color-scheme: dark)"
|
||||
scheme: slate
|
||||
primary: custom
|
||||
accent: custom
|
||||
toggle:
|
||||
icon: material/brightness-4
|
||||
name: Automatic mode
|
||||
features:
|
||||
- navigation.sections
|
||||
- navigation.top
|
||||
- navigation.footer
|
||||
- navigation.indexes
|
||||
- toc.follow
|
||||
- search.highlight
|
||||
- search.suggest
|
||||
- content.code.copy
|
||||
|
||||
extra_css:
|
||||
- assets/retro.css
|
||||
|
||||
markdown_extensions:
|
||||
- admonition
|
||||
- attr_list
|
||||
- def_list
|
||||
- footnotes
|
||||
- md_in_html
|
||||
- tables
|
||||
- toc:
|
||||
permalink: true
|
||||
- pymdownx.details
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:material.extensions.emoji.twemoji
|
||||
emoji_generator: !!python/name:material.extensions.emoji.to_svg
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.superfences
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
|
||||
validation:
|
||||
nav:
|
||||
omitted_files: info
|
||||
links:
|
||||
not_found: warn
|
||||
anchors: info
|
||||
absolute_links: info
|
||||
unrecognized_links: info
|
||||
|
||||
extra:
|
||||
generator: false
|
||||
social:
|
||||
- icon: material/view-grid-outline
|
||||
link: https://clang-retro.github.io/dos-sdk/projects/
|
||||
name: All clang-retro projects
|
||||
- icon: fontawesome/brands/github
|
||||
link: https://github.com/clang-retro
|
||||
name: clang-retro on GitHub
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
# MkDocs hook shared by the clang-retro documentation sites.
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright (C) clang-retro contributors.
|
||||
#
|
||||
# It lets a page take its text from the repository's own Markdown files, so
|
||||
# the READMEs stay the one place where things are written down:
|
||||
#
|
||||
# <!-- include README.md --> the whole file, without its title
|
||||
# <!-- include README.md "" --> the text before the first section
|
||||
# <!-- include README.md "Using it" --> one section (and its subsections),
|
||||
# without its heading; subheadings
|
||||
# move up to start at level 2
|
||||
# <!-- include README.md "Using it" only -->
|
||||
# the same without its subsections
|
||||
#
|
||||
# Links in every page are then fixed up: a link to a Markdown file that is
|
||||
# part of the site goes to its page, and a link to any other file in the
|
||||
# repository goes to that file on GitHub, so nothing is left pointing at a
|
||||
# path that the site does not have.
|
||||
#
|
||||
# Settings, in mkdocs.yml:
|
||||
#
|
||||
# extra:
|
||||
# retro:
|
||||
# root: . the repository's root, from mkdocs.yml
|
||||
# github: clang-retro/dos-sdk
|
||||
# branch: main
|
||||
# pages: repository files shown as site pages
|
||||
# README.md: index.md
|
||||
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
|
||||
from mkdocs.exceptions import PluginError
|
||||
|
||||
_INCLUDE = re.compile(r'^[ \t]*<!--\s*include\s+(\S+)(?:\s+"([^"]*)"(\s+only)?)?\s*-->[ \t]*$', re.M)
|
||||
_FENCE = re.compile(r'^\s*(```+|~~~+)')
|
||||
_HEADING = re.compile(r'^(#{1,6})\s+(.*?)\s*#*\s*$')
|
||||
_LINK = re.compile(r'(!?)\[((?:[^\[\]]|\[[^\]]*\])*)\]\(\s*<?([^)\s>]+)>?(\s+"[^"]*")?\s*\)')
|
||||
|
||||
_settings = {}
|
||||
|
||||
|
||||
def on_config(config):
|
||||
retro = dict(config.extra.get("retro", {}))
|
||||
base = os.path.dirname(config.config_file_path)
|
||||
retro["root"] = os.path.normpath(os.path.join(base, retro.get("root", ".")))
|
||||
docs = os.path.relpath(config.docs_dir, retro["root"]).replace(os.sep, "/")
|
||||
retro["docs"] = "" if docs == "." else docs
|
||||
retro.setdefault("branch", "main")
|
||||
retro.setdefault("pages", {})
|
||||
if "github" not in retro:
|
||||
raise PluginError("extra.retro.github is not set in mkdocs.yml")
|
||||
_settings.clear()
|
||||
_settings.update(retro)
|
||||
return config
|
||||
|
||||
|
||||
def _lines_outside_fences(lines):
|
||||
"""Yields (index, line, in_fence) for each line."""
|
||||
fence = None
|
||||
for i, line in enumerate(lines):
|
||||
m = _FENCE.match(line)
|
||||
if fence is None and m:
|
||||
fence = m.group(1)[0] * 3
|
||||
yield i, line, True
|
||||
continue
|
||||
if fence is not None:
|
||||
if line.strip().startswith(fence):
|
||||
fence = None
|
||||
yield i, line, True
|
||||
continue
|
||||
yield i, line, False
|
||||
|
||||
|
||||
def _section(text, name, path, only=False):
|
||||
lines = text.split("\n")
|
||||
heads = [(i, len(m.group(1)), m.group(2))
|
||||
for i, line, code in _lines_outside_fences(lines)
|
||||
if not code and (m := _HEADING.match(line))]
|
||||
if name is None: # the whole file, without its title
|
||||
if heads and heads[0][1] == 1:
|
||||
del lines[heads[0][0]]
|
||||
return "\n".join(lines)
|
||||
if name == "": # before the first section
|
||||
start = heads[0][0] + 1 if heads and heads[0][1] == 1 else 0
|
||||
end = next((i for i, lvl, _ in heads if lvl > 1), len(lines))
|
||||
return "\n".join(lines[start:end])
|
||||
for n, (i, lvl, title) in enumerate(heads):
|
||||
if title == name:
|
||||
end = next((j for j, l2, _ in heads[n + 1:] if only or l2 <= lvl), len(lines))
|
||||
body = lines[i + 1:end]
|
||||
shift = lvl - 1
|
||||
out = []
|
||||
for _, line, code in _lines_outside_fences(body):
|
||||
m = None if code else _HEADING.match(line)
|
||||
if m:
|
||||
line = "#" * (len(m.group(1)) - shift) + " " + m.group(2)
|
||||
out.append(line)
|
||||
return "\n".join(out)
|
||||
raise PluginError(f'{path}: no section "{name}"')
|
||||
|
||||
|
||||
def _github(path, kind):
|
||||
repo, branch = _settings["github"], _settings["branch"]
|
||||
if kind == "raw":
|
||||
return f"https://raw.githubusercontent.com/{repo}/{branch}/{path}"
|
||||
return f"https://github.com/{repo}/{kind}/{branch}/{path}".rstrip("/")
|
||||
|
||||
|
||||
def _fix_links(text, source, page):
|
||||
"""Rewrites the relative links of text, written in the repository file
|
||||
`source`, for the site page `page` (both relative to the root)."""
|
||||
root, docs, pages = _settings["root"], _settings["docs"], _settings["pages"]
|
||||
|
||||
def fix(m):
|
||||
bang, label, target, title = m.groups()
|
||||
if target.startswith("#") and source != page:
|
||||
# A link to a section of an included file: its page, if the
|
||||
# section is shown on a page of its own (pages: README.md#x).
|
||||
site = pages.get(source + target)
|
||||
if site is not None:
|
||||
here = posixpath.dirname(page[len(docs) + 1:] if docs else page)
|
||||
return f"{bang}[{label}]({posixpath.relpath(site, here or '.')}{title or ''})"
|
||||
if re.match(r"^[a-z][a-z0-9+.-]*:", target, re.I) or target.startswith(("#", "/")):
|
||||
return m.group(0)
|
||||
path, _, anchor = target.partition("#")
|
||||
full = posixpath.normpath(posixpath.join(posixpath.dirname(source), path))
|
||||
if full.startswith(".."):
|
||||
return m.group(0)
|
||||
new = None
|
||||
site = pages.get(full)
|
||||
if site is None and full.startswith(docs + "/" if docs else ""):
|
||||
inside = full[len(docs) + 1:] if docs else full
|
||||
if os.path.isfile(os.path.join(root, full)):
|
||||
site = inside
|
||||
if site is not None:
|
||||
here = posixpath.dirname(page[len(docs) + 1:] if docs else page)
|
||||
new = posixpath.relpath(site, here or ".")
|
||||
elif bang:
|
||||
new = _github(full, "raw")
|
||||
else:
|
||||
kind = "tree" if os.path.isdir(os.path.join(root, full)) else "blob"
|
||||
new = _github(full, kind)
|
||||
if anchor:
|
||||
new += "#" + anchor
|
||||
return f"{bang}[{label}]({new}{title or ''})"
|
||||
|
||||
lines = text.split("\n")
|
||||
for i, line, code in _lines_outside_fences(lines):
|
||||
if not code:
|
||||
lines[i] = _LINK.sub(fix, line)
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def on_page_markdown(markdown, page, config, files):
|
||||
root, docs = _settings["root"], _settings["docs"]
|
||||
page_path = posixpath.join(docs, page.file.src_uri) if docs else page.file.src_uri
|
||||
|
||||
def include(m):
|
||||
rel, name, only = m.group(1), m.group(2), bool(m.group(3))
|
||||
path = os.path.join(root, rel)
|
||||
try:
|
||||
with open(path, encoding="utf-8") as f:
|
||||
text = f.read()
|
||||
except OSError as e:
|
||||
raise PluginError(f"{page.file.src_uri}: cannot include {rel}: {e}")
|
||||
return _fix_links(_section(text, name, rel, only), rel, page_path)
|
||||
|
||||
# Links in the page itself first, so that included text is not fixed twice.
|
||||
parts, last = [], 0
|
||||
for m in _INCLUDE.finditer(markdown):
|
||||
parts.append(_fix_links(markdown[last:m.start()], page_path, page_path))
|
||||
parts.append(include(m))
|
||||
last = m.end()
|
||||
parts.append(_fix_links(markdown[last:], page_path, page_path))
|
||||
return "".join(parts)
|
||||
@@ -0,0 +1,3 @@
|
||||
# The documentation site's build tools (mkdocs build, mkdocs serve).
|
||||
mkdocs==1.6.1
|
||||
mkdocs-material==9.8.1
|
||||
@@ -0,0 +1,69 @@
|
||||
# Build the documentation site with MkDocs, for every pull request and push,
|
||||
# and publish it on GitHub Pages from the default branch.
|
||||
#
|
||||
# Publishing needs Pages turned on once, with "GitHub Actions" as the source
|
||||
# (Settings > Pages > Build and deployment). Until then the site is built and
|
||||
# checked, and the deploy job is skipped with a notice.
|
||||
name: Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: docs-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: read
|
||||
pages: read
|
||||
outputs:
|
||||
pages: ${{ steps.pages.outputs.enabled }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
cache: pip
|
||||
cache-dependency-path: .docs/requirements.txt
|
||||
- run: pip install -r .docs/requirements.txt
|
||||
- run: mkdocs build --strict
|
||||
- name: Is GitHub Pages on?
|
||||
id: pages
|
||||
if: github.event_name != 'pull_request'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
if gh api "repos/${{ github.repository }}/pages" --jq .build_type | grep -qx workflow; then
|
||||
echo enabled=true >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "::notice::GitHub Pages is not set to deploy from GitHub Actions in this repository, so the site is built but not published."
|
||||
fi
|
||||
- uses: actions/upload-pages-artifact@v3
|
||||
if: steps.pages.outputs.enabled == 'true'
|
||||
with:
|
||||
path: site
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
if: needs.build.outputs.pages == 'true'
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
pages: write
|
||||
id-token: write
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deploy.outputs.page_url }}
|
||||
steps:
|
||||
- id: deploy
|
||||
uses: actions/deploy-pages@v4
|
||||
@@ -1,3 +1,4 @@
|
||||
build/
|
||||
/*.log
|
||||
/*.bmp
|
||||
/site/
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
@@ -0,0 +1,36 @@
|
||||
/* clang-retro documentation theme: phosphor green on a dark CRT.
|
||||
SPDX-License-Identifier: AGPL-3.0-only */
|
||||
|
||||
:root {
|
||||
--md-primary-fg-color: #0b1a10;
|
||||
--md-primary-fg-color--light: #16301e;
|
||||
--md-primary-fg-color--dark: #050d08;
|
||||
--md-primary-bg-color: #6cf08a;
|
||||
--md-primary-bg-color--light: #6cf08ab3;
|
||||
--md-accent-fg-color: #12a33c;
|
||||
--md-accent-fg-color--transparent: #12a33c1a;
|
||||
--md-typeset-a-color: #0d7f2f;
|
||||
}
|
||||
|
||||
[data-md-color-scheme="slate"] {
|
||||
--md-default-bg-color: #0c120e;
|
||||
--md-default-bg-color--light: #0c120eb3;
|
||||
--md-code-bg-color: #101a13;
|
||||
--md-typeset-a-color: #6cf08a;
|
||||
--md-accent-fg-color: #9dffb3;
|
||||
}
|
||||
|
||||
.md-header__title, .md-nav__title {
|
||||
font-family: var(--md-code-font-family);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.md-header__button.md-logo img { border-radius: 4px; }
|
||||
|
||||
/* Wide tables (target lists, call tables) scroll instead of squeezing. */
|
||||
.md-typeset table:not([class]) { font-size: 0.72rem; }
|
||||
|
||||
/* Cards on the project and home pages. */
|
||||
.md-typeset .grid.cards > ul > li { border-color: var(--md-accent-fg-color--transparent); }
|
||||
.md-typeset .grid.cards > ul > li:hover { border-color: var(--md-accent-fg-color); }
|
||||
.md-typeset figure img { border: 1px solid var(--md-default-fg-color--lightest); border-radius: 4px; }
|
||||
@@ -0,0 +1,3 @@
|
||||
# Building
|
||||
|
||||
<!-- include README.md "Building" -->
|
||||
@@ -0,0 +1,3 @@
|
||||
# What is there
|
||||
|
||||
<!-- include README.md "What is there" -->
|
||||
@@ -0,0 +1,3 @@
|
||||
# Contributing
|
||||
|
||||
<!-- include CONTRIBUTING.md -->
|
||||
@@ -0,0 +1,3 @@
|
||||
# Differences from Visual C++ MFC
|
||||
|
||||
<!-- include README.md "Differences from Visual C++ MFC" -->
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
hide:
|
||||
- navigation
|
||||
---
|
||||
|
||||
# clang-retro MFC
|
||||
|
||||
<!-- include README.md "" -->
|
||||
|
||||
<div class="grid cards" markdown>
|
||||
|
||||
- :material-hammer-wrench: **Build**
|
||||
|
||||
---
|
||||
|
||||
[Build the library](building.md) for any win32-sdk sysroot, or for stock MinGW-w64.
|
||||
|
||||
- :material-format-list-checks: **What is there**
|
||||
|
||||
---
|
||||
|
||||
[The classes and features](contents.md) that are implemented.
|
||||
|
||||
- :material-compare-horizontal: **Differences**
|
||||
|
||||
---
|
||||
|
||||
[Where it differs from Visual C++ MFC](differences.md), and why.
|
||||
|
||||
- :material-test-tube: **Testing**
|
||||
|
||||
---
|
||||
|
||||
[The tests](testing.md), in Wine and natively.
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
# License
|
||||
|
||||
<!-- include README.md "License" -->
|
||||
@@ -0,0 +1,9 @@
|
||||
# Plans and layout
|
||||
|
||||
## Plans
|
||||
|
||||
<!-- include README.md "Plans" -->
|
||||
|
||||
## Layout
|
||||
|
||||
<!-- include README.md "Layout" -->
|
||||
@@ -0,0 +1,3 @@
|
||||
# Testing
|
||||
|
||||
<!-- include README.md "Testing" -->
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
# The documentation site: https://clang-retro.github.io/mfc/
|
||||
# Build it with `pip install -r .docs/requirements.txt` and `mkdocs serve`.
|
||||
INHERIT: .docs/base.yml
|
||||
site_name: clang-retro MFC
|
||||
site_description: An independent implementation of the Microsoft Foundation Classes for clang and MinGW-w64
|
||||
site_url: https://clang-retro.github.io/mfc/
|
||||
repo_url: https://github.com/clang-retro/mfc
|
||||
repo_name: clang-retro/mfc
|
||||
edit_uri: ""
|
||||
hooks:
|
||||
- .docs/hooks.py
|
||||
|
||||
extra:
|
||||
retro:
|
||||
github: clang-retro/mfc
|
||||
branch: main
|
||||
pages:
|
||||
README.md: index.md
|
||||
CONTRIBUTING.md: contributing.md
|
||||
|
||||
nav:
|
||||
- "Home": index.md
|
||||
- "Building": building.md
|
||||
- "Testing": testing.md
|
||||
- "What is there": contents.md
|
||||
- "Differences from Visual C++": differences.md
|
||||
- "Plans and layout": plans.md
|
||||
- "Contributing": contributing.md
|
||||
- "License": license.md
|
||||
- "All clang-retro projects": https://clang-retro.github.io/dos-sdk/projects/
|
||||
Reference in new issue
Block a user