-
Notifications
You must be signed in to change notification settings - Fork 5
Cleanup PDF docs #1130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Cleanup PDF docs #1130
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # DFetch add workflow | ||
|
|
||
| Add a new project to `dfetch.yaml` and fetch it. | ||
|
|
||
| The user may pass a URL or description as `$ARGUMENTS`. If they did not, ask for the URL before proceeding. | ||
|
|
||
| ## Step 1 — Read the manifest | ||
|
|
||
| Read `dfetch.yaml` to understand the existing remotes and project patterns. | ||
|
|
||
| ## Step 2 — Classify the URL | ||
|
|
||
| Determine the VCS type from the URL: | ||
|
|
||
| - **archive** — URL ends in `.zip`, `.tar.gz`, `.tar.bz2`, `.tar.xz`, or similar. | ||
| - **svn** — URL contains `svn`, uses `svn+ssh://`, or the user says so. | ||
| - **git** — everything else. | ||
|
|
||
| ## Step 3 — Gather details | ||
|
|
||
| `dfetch add` auto-detects the default branch and guesses a destination, so you only need to ask about things it cannot infer. Use `AskUserQuestion` to collect what you don't yet know: | ||
|
|
||
| **For git and SVN:** | ||
|
|
||
| Only ask what the user hasn't already told you: | ||
| - **Name** — defaults to the repo name from the URL; confirm or let the user override. | ||
| - **Destination** (`dst`) — where in the repo the files should land; `dfetch add` guesses from existing project paths, but ask if the user has a preference. | ||
| - **Version** — branch, tag, or revision to pin. Leave blank to track the default branch. | ||
| - **Source path** (`src`) — sub-path or glob inside the remote repo (e.g. `lib/` or `*.h`). Leave blank to copy everything. | ||
| - **Ignore patterns** — glob patterns to exclude. Leave blank for none. | ||
|
|
||
| **For archives, also ask:** | ||
| - **Source path** (`src`) — sub-directory inside the archive to copy (archives often have a single wrapping top-level directory that dfetch strips automatically). | ||
| - **Ignore patterns** — globs to filter out unwanted files (other font families, binary formats, etc.). | ||
| - **Integrity hash** — whether to verify the download (strongly recommended; you will compute it). | ||
|
|
||
| ## Step 4 — Add the project | ||
|
|
||
| **Git and SVN** — use the CLI, which appends the entry to `dfetch.yaml` and records the resolved remote: | ||
|
|
||
| ```bash | ||
| dfetch add --name <name> --dst <dst> [--src <src>] [--version <version>] \ | ||
| [--ignore <p1> <p2> ...] <url> | ||
| ``` | ||
|
|
||
| Omit flags for fields the user left blank; `dfetch add` will fill in sensible defaults. | ||
|
|
||
| **Archives** — edit `dfetch.yaml` directly with the Edit tool. The CLI does not support `vcs: archive`, `integrity:`, or archive-specific `src` paths. Follow the style of existing archive entries: | ||
|
|
||
| ```yaml | ||
| - name: <name> | ||
| remote: <remote> # use an existing remote if its url-base is a prefix of the URL; omit otherwise | ||
| vcs: archive | ||
| src: <path-in-archive> # omit if copying from the archive root | ||
| dst: <dst> | ||
| repo-path: <url-or-path> | ||
| ignore: | ||
| - <pattern> | ||
| integrity: | ||
| hash: sha256:<hash> | ||
| ``` | ||
|
|
||
| Compute the hash before writing the entry: | ||
|
|
||
| ```bash | ||
| curl -sL <url> | sha256sum | ||
| ``` | ||
|
|
||
| When reusing an existing remote, `repo-path` is the URL suffix after the remote's `url-base`. When no remote matches, omit `remote:` and use the full URL as `repo-path`. | ||
|
|
||
| ## Step 5 — Fetch and verify | ||
|
|
||
| Run `dfetch update <name>`. If it fails: | ||
|
|
||
| | Error | Fix | | ||
| |---|---| | ||
| | `src … not found in archive` | Inspect the archive with `unzip -l <file>` or `tar -tf <file>`. If the archive has a single top-level wrapper directory, dfetch strips it — adjust `src` accordingly. | | ||
| | Integrity mismatch | Recompute the hash and update the `integrity` field. | | ||
| | Remote not found | Check that `remote:` matches a name in the `remotes:` list. | | ||
| | Branch/tag not found | Run `dfetch add -i <url>` in a terminal to browse available versions interactively, then copy the chosen value back into the manifest. | | ||
|
|
||
| ## Step 6 — Confirm | ||
|
|
||
| Show the user the new entry that was added to `dfetch.yaml` and list the files that were fetched to `dst`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| """Sphinx extension that makes section IDs unique across a document. | ||
|
|
||
| sphinx-argparse generates identical section IDs (e.g. | ||
| ``dfetch.__main__-create_parser-positional-arguments``) for every subcommand | ||
| because they all share the same argparse function. The extension's own | ||
| ``ensure_unique_ids`` helper only deduplicates within a single directive call, | ||
| so IDs remain duplicate across subcommand blocks. These duplicates produce | ||
| ``multiply-defined label`` warnings in the LaTeX output. | ||
|
|
||
| This extension runs a second deduplication pass over the fully-resolved | ||
| doctree, appending ``_repeat1``, ``_repeat2``, … suffixes to any duplicate IDs | ||
| that survive after sphinx-argparse's own pass. | ||
|
|
||
| Register in ``conf.py``:: | ||
|
|
||
| extensions = [..., "unique_section_ids"] | ||
| """ | ||
|
|
||
| from typing import Any | ||
|
|
||
| from docutils import nodes | ||
| from sphinx.application import Sphinx | ||
|
|
||
|
|
||
| def _deduplicate_ids(_app: Sphinx, doctree: nodes.document, _fromdocname: str) -> None: | ||
| """Rename duplicate section IDs within a resolved doctree. | ||
|
|
||
| Traverses every ``section`` node in *doctree* and ensures each ID is | ||
| unique. When a collision is detected the duplicate receives a | ||
| ``_repeat<n>`` suffix (incrementing *n* until the result is free), which | ||
| mirrors the strategy used by sphinx-argparse's own ``ensure_unique_ids`` | ||
| helper but applies it document-wide rather than per-directive. | ||
|
|
||
| Args: | ||
| _app: The Sphinx application object (unused). | ||
| doctree: The fully-resolved document tree being processed. | ||
| _fromdocname: The document name that produced the tree (unused). | ||
| """ | ||
| seen: set[str] = set() | ||
| for node in doctree.traverse(nodes.section): | ||
| new_ids: list[str] = [] | ||
| for id_ in node["ids"]: | ||
| if id_ not in seen: | ||
| seen.add(id_) | ||
| new_ids.append(id_) | ||
| else: | ||
| counter = 1 | ||
| while f"{id_}_repeat{counter}" in seen: | ||
| counter += 1 | ||
| unique_id = f"{id_}_repeat{counter}" | ||
| seen.add(unique_id) | ||
| new_ids.append(unique_id) | ||
| node["ids"] = new_ids | ||
|
|
||
|
|
||
| def setup(app: Sphinx) -> dict[str, Any]: | ||
| """Register the section-ID deduplication handler with Sphinx. | ||
|
|
||
| Args: | ||
| app: The Sphinx application object. | ||
|
|
||
| Returns: | ||
| Extension metadata dictionary. | ||
| """ | ||
| app.connect("doctree-resolved", _deduplicate_ids) | ||
| return {"version": "0.1", "parallel_read_safe": True} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.