Skip to content

About

πŸ“„ Turn a public GitHub repository into a PDF and one JPG per page.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

26 Commits

Folders and files

Repository files navigation

GitHub Project Convert Docs

Python License

GitHub Project Convert Docs logo

GitHub Project Convert Docs turns the link of a public GitHub repository into one PDF, with one JPG per page, that a reader opens without GitHub. It exists because a shared project is only a link today, and a link shows a reader nothing until they click it and find their own way around GitHub.

Table of Contents

  1. Setup
  2. Usage
  3. Configuration
  4. Data
  5. Project Structure
  6. Development
  7. Known Limitations
  8. License

Setup

Setup runs once per machine: follow Windows or Linux, then check the install. A returning reader activates the environment and starts at Usage.

Each platform has two routes, a venv or a conda environment. Pick one. Both use Python 3.13, the version the project is tested on. First, clone the repository.

git clone https://github.com/rahfianugerah/github-project-convert-docs.git
cd github-project-convert-docs

Windows

Supported on Windows 11. Run the commands in PowerShell.

Route A: venv. Needs Python 3.13 from the python.org installer. Run py -0, which must list -V:3.13. Then create and activate the environment.

py -3.13 -m venv .venv
.venv\Scripts\Activate.ps1

If PowerShell blocks the script, run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser once, then activate again. In Git Bash, activate with source .venv/Scripts/activate instead.

Route B: conda. Needs Miniconda or Anaconda. Run the commands in the Anaconda Prompt, or in PowerShell after conda init powershell and a new shell.

conda create -n github-project-convert-docs python=3.13
conda activate github-project-convert-docs

On either route, check the interpreter with python --version, which must print Python 3.13 or newer. Then install the locked dependencies and download Chromium.

pip install -r requirements.lock
pip install -e . --no-deps
playwright install chromium

Without playwright install chromium, every run stops with error: Chromium is not installed, run: playwright install chromium.

Linux

Supported on Debian 12 and 13, and Ubuntu 22.04, 24.04, and 26.04. Run the commands in a shell as a normal user, never as root.

Route A: venv. Debian 12, Ubuntu 22.04, and Ubuntu 24.04 default to an older Python, so install Python 3.13 and its venv module first. Check it with python3.13 --version, which must print Python 3.13.x. Without them, the command fails, or the install stops with requires a different Python. Then create and activate the environment.

python3.13 -m venv .venv
source .venv/bin/activate

Route B: conda. Needs Miniconda or Anaconda. Conda brings its own Python 3.13, so the system Python does not matter.

conda create -n github-project-convert-docs python=3.13
conda activate github-project-convert-docs

On either route, check the interpreter with python --version, which must print Python 3.13 or newer. Then install the locked dependencies and download Chromium.

pip install -r requirements.lock
pip install -e . --no-deps
playwright install chromium

Without playwright install chromium, every run stops with error: Chromium is not installed, run: playwright install chromium.

Fonts and libraries. Install the font packages fonts-noto-cjk and fonts-noto-color-emoji, and the system libraries Chromium needs. With the environment active, run the two commands below. Playwright calls sudo itself, so the first command has no sudo prefix.

playwright install-deps chromium
sudo apt-get install -y fonts-noto-cjk fonts-noto-color-emoji

Chromium's sandbox must start. A host that blocks it stops the run with error: Chromium could not start with its sandbox, and the run never retries without the sandbox. Chromium refuses to start its sandbox as root, so never run the CLI as root. On Ubuntu 24.04 and later, run sysctl -n kernel.apparmor_restrict_unprivileged_userns. When it prints 1, fix it with an AppArmor profile for the Chromium binary that grants userns, as described in the Chromium AppArmor user namespace guide and the Ubuntu 24.04 release notes.

Check the Install

With the environment active, run the command below. The usage line prints and the command exits with code 0.

python main.py --help

Usage

Give the command a link to a public repository, in the form https://github.com/<owner>/<repo>.

python main.py --src="https://github.com/sindresorhus/awesome"

A successful run prints one final line that names the PDF and the number of page images. This is the line for sindresorhus/awesome.

Document written to output/sindresorhus-awesome/sindresorhus-awesome.pdf, with 30 page images

Any link to a repository on github.com or www.github.com works, including a link with /tree/main, a trailing .git, or a query string. The run ignores everything after the repository name.

The document holds, in order:

  • Cover. The full name, the description, the link to the repository, the date of generation in UTC, the topics, and one line of facts: the language, the license, the latest release, the last push, the stars, and the forks.
  • At a glance. One status for each of README, Releases, Packages, Contributing, Code of Conduct, Security policy, and License.
  • Sections. About, from the README; Releases; Packages; Contributing; Code of Conduct; Security Policy; and License. Each starts on a new page. A section with no content is left out.

The exit codes are these.

  • 0: the document was written.
  • 1: the run failed. The last line on standard error says why.
  • 2: the usage line was printed. The --src value is missing or is not a GitHub repository link, or the command has an option other than --src, -h, or --help, or a positional argument.

A document over 300 pages stops the run. A PDF over 100 MB prints a warning on standard error.

Configuration

The project reads one variable. Its name is the only value this file shows.

Variable Required Description
GITHUB_TOKEN No A GitHub token. Without it, packages are not checked and the API rate limit is lower

To set the token, copy the template and fill in the value.

cp .env.example .env

On Windows PowerShell, use Copy-Item .env.example .env instead.

  • Scope. Use a classic token with only read:packages and an expiry date. Never give it repo.
  • Source. The token is never read from a flag. It is read from the environment, or from the .env file at the project root, and from no other file.
  • Another tool's token. A GITHUB_TOKEN that another tool already set is used if it is present.
  • Printed line. Every run that has a token prints Using GITHUB_TOKEN from the environment., whether the token came from the environment or from .env.
  • Invalid value. A value that is not 1 to 255 characters from A-Z, a-z, 0-9, and _ stops the run with error: GITHUB_TOKEN is not a valid token. The message never echoes the value.
  • Rejected token. A token that GitHub rejects stops the run with error: GITHUB_TOKEN was rejected by GitHub, fix it or remove it.
  • Never commit .env. It is gitignored.

Data

The run reads public data only, from GitHub's REST API at https://api.github.com and from GitHub's content hosts. A private or internal repository gets the same message as a missing one. Nothing here is committed.

Item Location Notes
Document output/<owner>-<repo>/ Gitignored. A second run for the same repository replaces the first
Temporary files A folder inside output/ Gitignored. Removed when the run ends. A killed run can leave it behind
Chromium profile The operating system's temp folder Outside the project, so not committed
Token .env at the project root Gitignored. Optional

Project Structure

assets/logo.png          # the project logo
main.py                  # the one command
app/                     # the code the command runs
  client.py              # guarded GitHub access: the one path every request takes
  content.py             # sanitizes GitHub HTML and inlines every image
  document.py            # the cover, At a glance, every section, and the print style
  github.py              # the repository, its README, community files, and license
  models.py              # shared data
  releases.py            # releases and packages
  render.py              # the PDF from a locked-down Chromium, and the page images
  settings.py            # the project root, the host lists, every limit, and the token
  source.py              # the link check
test/                    # pytest tests
scripts/test-all.sh      # every check and test, in order
docs/                    # PRD and SRS
pyproject.toml           # the project metadata and the direct dependencies
requirements.lock        # every dependency, pinned
.env.example             # the one variable's name

Development

Run every check and every test with the environment active.

bash scripts/test-all.sh

The script runs ruff format --check ., ruff check ., mypy main.py app/, and pytest, in that order, and stops at the first failure. On Windows, run it in Git Bash.

Branch shape. main is the only permanent branch. A working branch is named <type>/<description> and merged back into main as soon as its work runs.

No container. The project ships no Dockerfile, no image, and no compose file. It runs on the host's Python and Chromium.

Release audit. pip-audit runs locally against requirements.lock at each release, not in CI. Leave the environment first, with deactivate for a venv or conda deactivate for conda, because a --user install fails inside a venv. From the project root, run python -m pip install --user pipx and python -m pipx ensurepath, once. Open a new shell after ensurepath, change to the project root, and run pipx run pip-audit -r requirements.lock. The command installs pip-audit in its own environment, so the project environment and requirements.lock never hold it. The project has no CI workflow.

For commits, pull requests, and tests, read CONTRIBUTING.md. To report a vulnerability, read SECURITY.md.

Known Limitations

  • A token is optional, but without one packages are not checked. GitHub lists a repository's packages only to a classic token with read:packages, so a run without GITHUB_TOKEN shows Not checked for Packages. Every other section works without a token.
  • Only Python 3.13 is tested. A newer Python installs the locked dependencies and runs the tool, but the test suite checks for 3.13 and fails its version test on any other version.
  • No proxy is taken from the environment. The HTTP client sets trust_env=False, so a machine that reaches GitHub only through a proxy cannot run the tool.
  • An owner with a full page of 100 packages of one type gets Not checked for Packages. The note on standard error then blames the token, although one is set. The note comes from FR-PKG-03 in docs/SRS.md.
  • Only the 5 newest releases are shown. The cap is open question 9 in docs/PRD.md, so an older release is not listed.
  • An image past a cap shows its alt text. The caps are 50 images, 5 MB per image, 50 MB of images in total, 25 million pixels per image, 100 million pixels per document, and 60 s for all image downloads. Each cap keeps a run bounded, as NFR-SEC-04, NFR-SEC-05, and NFR-SEC-09 in docs/SRS.md require.
  • A file or release note over 1 MB is shown as a link. Its section reads This file is too large to include. Read it on GitHub: and then the link, so the text is not rendered. The limit is NFR-SEC-05 in docs/SRS.md, with FR-MD-07 for the link.
  • Without a token, GitHub's limit of 60 requests an hour allows about three runs. GitHub allows 60 unauthenticated requests an hour from one IP address, and a run sends at most 20 of them, per NFR-PERF-02 in docs/SRS.md.

License

MIT. See LICENSE.

About

πŸ“„ Turn a public GitHub repository into a PDF and one JPG per page.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages