|
| 1 | +--- |
| 2 | +title: Repository Improvement Plan (CLA Review) |
| 3 | +this_file: REVIEW/TODO-cla.md |
| 4 | +--- |
| 5 | + |
| 6 | +# Improvement Plan and Proposals |
| 7 | + |
| 8 | +Context: This repo builds and hosts documentation for the FontLab 7 Python API and PythonQt using pydocmk2 (Python 2.7) and MkDocs Material. Below is a concrete, example-driven plan to improve maintainability, reproducibility, and contributor experience. No code changes are performed here; this document proposes them. |
| 9 | + |
| 10 | +## Goals |
| 11 | + |
| 12 | +- Reliable, one-command builds for both `fontlab7` and `pythonqt` docs. |
| 13 | +- Clear separation of sources vs. generated artefacts; deterministic outputs. |
| 14 | +- Modernized build path and CI to publish to GitHub Pages automatically. |
| 15 | +- Contributor-friendly docs and CLA flow with examples and templates. |
| 16 | + |
| 17 | +## Observations |
| 18 | + |
| 19 | +- Generated HTML is committed in `docs/` and is large; rebuild steps require Python 2.7 and local FontLab to produce sources for MkDocs. |
| 20 | +- Two parallel doc trees (`fontlab7/`, `pythonqt/`) have near-duplicate configuration and theme customizations. |
| 21 | +- `README.md` focuses on manual builds; there’s no automated build script or CI. |
| 22 | +- No `CONTRIBUTING.md`, PR/issue templates, or clear “generated vs. source” guidance. |
| 23 | + |
| 24 | +## Proposed Improvements (with examples) |
| 25 | + |
| 26 | +1) Build Automation (single entry point) |
| 27 | +- Add a top-level task runner so contributors don’t memorize commands. |
| 28 | +- Example Makefile snippet: |
| 29 | + ```make |
| 30 | + .PHONY: build build-fontlab7 build-pythonqt serve clean |
| 31 | + |
| 32 | + build: build-fontlab7 build-pythonqt |
| 33 | + |
| 34 | + build-fontlab7: |
| 35 | + cd fontlab7/build && python2 -m mkdocs build -v -f ../mkdocs.yml --dirty |
| 36 | + |
| 37 | + build-pythonqt: |
| 38 | + cd pythonqt/build && python2 -m mkdocs build -v -f ../mkdocs.yml --dirty |
| 39 | + |
| 40 | + serve: |
| 41 | + cd fontlab7 && python2 -m mkdocs serve -f mkdocs.yml |
| 42 | + |
| 43 | + clean: |
| 44 | + rm -rf docs/ docs/pythonqt/ |
| 45 | + ``` |
| 46 | + |
| 47 | +2) Reproducible Environments |
| 48 | +- Document pinned versions for MkDocs and theme used with Python 2 runtime (or ship a container). |
| 49 | +- Example: `Dockerfile` to encapsulate the Python 2 toolchain and mkdocs build: |
| 50 | + ```Dockerfile |
| 51 | + FROM python:2.7-slim |
| 52 | + RUN pip install --no-cache-dir git+https://github.com/twardoch/pydocmk2 mkdocs==0.17.5 mkdocs-material==2.9.4 |
| 53 | + WORKDIR /src |
| 54 | + CMD ["bash", "-lc", "cd fontlab7/build && python -m mkdocs build -f ../mkdocs.yml && cd ../../pythonqt/build && python -m mkdocs build -f ../mkdocs.yml"] |
| 55 | + ``` |
| 56 | +- Alternative: Prebuilt GH Actions setup using `actions/setup-python@v4` with a Python 2 toolchain (if available) or container job. |
| 57 | + |
| 58 | +3) Generated Artefact Policy |
| 59 | +- Treat `docs/` as build output; either: |
| 60 | + - Keep committed only on a dedicated `gh-pages` branch (preferred), or |
| 61 | + - Continue committing to `main`, but clarify that `docs/` is generated and add regeneration policy. |
| 62 | +- Example README blurb: |
| 63 | + > The `docs/` directory is generated by MkDocs; do not edit HTML directly. Edit sources under `fontlab7/srcdocs` or `pythonqt/srcdocs`, then rebuild. |
| 64 | +
|
| 65 | +4) CI/CD for Publishing (GitHub Pages) |
| 66 | +- Add a workflow that builds and deploys on tag or main branch updates. |
| 67 | +- Example `.github/workflows/docs.yml` (container-based for Python 2): |
| 68 | + ```yaml |
| 69 | + name: Build and Deploy Docs |
| 70 | + on: |
| 71 | + push: |
| 72 | + branches: [ main ] |
| 73 | + tags: [ 'v*' ] |
| 74 | + jobs: |
| 75 | + build: |
| 76 | + runs-on: ubuntu-latest |
| 77 | + container: python:2.7-slim |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v3 |
| 80 | + - run: pip install git+https://github.com/twardoch/pydocmk2 mkdocs==0.17.5 mkdocs-material==2.9.4 |
| 81 | + - run: cd fontlab7/build && python -m mkdocs build -f ../mkdocs.yml |
| 82 | + - run: cd pythonqt/build && python -m mkdocs build -f ../mkdocs.yml || true |
| 83 | + - uses: actions/upload-pages-artifact@v3 |
| 84 | + with: |
| 85 | + path: docs |
| 86 | + deploy: |
| 87 | + needs: build |
| 88 | + permissions: |
| 89 | + pages: write |
| 90 | + id-token: write |
| 91 | + environment: |
| 92 | + name: github-pages |
| 93 | + url: ${{ steps.deployment.outputs.page_url }} |
| 94 | + runs-on: ubuntu-latest |
| 95 | + steps: |
| 96 | + - id: deployment |
| 97 | + uses: actions/deploy-pages@v4 |
| 98 | + ``` |
| 99 | +- Note: The PythonQt build may be optional if its sources require a FontLab-installed environment. The MkDocs phase can still publish existing generated content. |
| 100 | +
|
| 101 | +5) Deduplicate and Centralize Theme/Config |
| 102 | +- Extract shared MkDocs settings (extensions, analytics, palette, logo, extra_css) into a common YAML and anchor-merge them in both `mkdocs.yml` files. |
| 103 | +- Example pattern (YAML anchors): |
| 104 | + ```yaml |
| 105 | + # common.yml |
| 106 | + x-theme: &theme |
| 107 | + name: material |
| 108 | + logo: https://.../icon-fontlab-7.png |
| 109 | + palette: { primary: indigo } |
| 110 | + x-markdown: &markdown_ext |
| 111 | + - attr_list |
| 112 | + - def_list |
| 113 | + - tables |
| 114 | + - pymdownx.superfences: { highlight_code: true } |
| 115 | + ``` |
| 116 | +- Then in `fontlab7/mkdocs.yml` and `pythonqt/mkdocs.yml`, import or copy-with-anchors to avoid drift. |
| 117 | + |
| 118 | +6) Clear Source Structure and Examples |
| 119 | +- Add short `README.md` files inside `fontlab7/srcdocs/` and `pythonqt/srcdocs/` describing: |
| 120 | + - Where to add hand-written docs (`docs/`), and how `pre/` and `post/` files work. |
| 121 | + - Concrete examples (e.g., `typerig.core.objects.cubicbezier.md` → pre/post pages) with a before/after snippet. |
| 122 | +- Example guidance snippet: |
| 123 | + ```md |
| 124 | + To prepend content to an API page generated as `fontgate.fgGlyph.md`, create `srcdocs/pre/fontgate.fgGlyph.md` with an intro, usage example, and notes. |
| 125 | + ``` |
| 126 | +
|
| 127 | +7) Contributor Experience and CLA Flow |
| 128 | +- Add `CONTRIBUTING.md` with prerequisites, build commands, and CLA requirement. |
| 129 | +- Add issue/PR templates to encourage adding `pre/`/`post/` docs and repro steps for build issues. |
| 130 | +- Link CLA prominently in `README.md` and `CONTRIBUTING.md`. |
| 131 | + |
| 132 | +8) Modernization Strategy (medium-term) |
| 133 | +- Python 2.7 is EOL; plan a migration path: |
| 134 | + - Verify pydocmk2 compatibility with Python 3 (or alternatives like `pdoc`, `pdoc3`, `sphinx`, or mkdocstrings). |
| 135 | + - Prototype generating Markdown for a subset of modules with Python 3 toolchain; compare output. |
| 136 | + - If FontLab export step is the blocker, consider exporting intermediate JSON or reStructuredText and converting to Markdown with a Python 3 tool. |
| 137 | + |
| 138 | +9) Housekeeping |
| 139 | +- Ensure `.gitignore` excludes local caches and temporary files (e.g., `*.vfpyc`, `.DS_Store`, `site/`, `.pytest_cache/`). |
| 140 | +- Add `CODE_OF_CONDUCT.md` and `SECURITY.md` for standardization. |
| 141 | +- Add `mkdocs serve` instructions and a port note for local preview. |
| 142 | + |
| 143 | +## Phased Plan |
| 144 | + |
| 145 | +- Phase 0: Document status |
| 146 | + - Clarify in `README.md` what is generated vs. source; add regeneration and publishing policy. |
| 147 | + |
| 148 | +- Phase 1: Automation |
| 149 | + - Add Makefile and a minimal CI workflow to build and publish existing docs to GitHub Pages. |
| 150 | + - Keep PythonQt build optional if data is not available in CI. |
| 151 | + |
| 152 | +- Phase 2: Config hygiene |
| 153 | + - Deduplicate MkDocs config (anchors or a shared snippet). Consolidate custom CSS in a single source and symlink or copy as needed. |
| 154 | + |
| 155 | +- Phase 3: Contributor enablement |
| 156 | + - Add `CONTRIBUTING.md`, templates, and `srcdocs/` READMEs with concrete examples. |
| 157 | + |
| 158 | +- Phase 4: Modernization prototype |
| 159 | + - Spike a Python 3 build path for one module group using mkdocstrings or pdoc. Compare fidelity and decide on migration roadmap. |
| 160 | + |
| 161 | +## Risks and Mitigations |
| 162 | + |
| 163 | +- Python 2 toolchain availability: Use containerized builds to ensure longevity. |
| 164 | +- FontLab dependency for generation: Capture generated Markdown in repo (not just HTML) to reduce reliance on local FontLab for every rebuild; document when regeneration is necessary. |
| 165 | +- CI stability: Pin MkDocs and theme versions; test on a branch before switching Pages to Actions. |
| 166 | + |
| 167 | +## Success Criteria |
| 168 | + |
| 169 | +- `make build` (or one equivalent command) produces the same `docs/` artefacts deterministically on a clean machine. |
| 170 | +- GitHub Pages deploys automatically on merges to `main`. |
| 171 | +- Contributors can add/modify `pre/` and `post/` docs with clear guidance and examples. |
| 172 | +- Reduced configuration drift between `fontlab7` and `pythonqt` trees. |
| 173 | + |
0 commit comments