Skip to main content

Style your documents - convert Markdown files and GitHub issues into styled PDF documents in your corporate skin.

Project description

📄 docskin

Build Status image Security Status Ruff PyPI Version

Coverage

Coverage Report
FileStmtsMissBranchBrPartCoverMissing
docskin
   __init__.py0000100% 
   __main__.py66200%3–18
docskin/cli
   __init__.py2312192%57
docskin/cli/commands
   __init__.py4000100% 
   github_issue.py14000100% 
   markdown_file.py12000100% 
   markdown_folder.py17040100% 
   setup.py510080%15
docskin/core
   __init__.py0000100% 
   content.py3984277%55–61, 72–76
   converter.py5214196%54
   github_api.py2762176%34, 39, 45–48
   mermaid.py27000100% 
   setup.py32224028%32, 44–85, 96–99, 109–110
   styles.py19000100% 
   tokens.py20156019%44–64
TOTAL2976028576% 

Style your documents - convert Markdown files and GitHub issues into styled PDF documents in your corporate skin – with full support for CSS themes, logos, and directory processing.

🔧 Installation

uv sync

or in development mode:

uv sync --editable .

🚀 Usage

📁 Convert Markdown Files in a Directory

Converts all .md files in a directory to PDF format.

docskin md-dir \
  --input ./docs \
  --output ./pdfs \
  --css-style assets/markdown-dark.css \
  --logo assets/bosch-logo.png

📄 Convert a Single Markdown File

Converts a single file to PDF format.

docskin md \
  --input README.md \
  --output README.pdf \
  --css-style assets/minimal.css

🐙 Convert GitHub Issue to PDF

Converts a GitHub issue (e.g. on Bosch DevCloud) to PDF.

docskin github \
  --repo aos-stakeholder-tools/recompute-driving-cluster \
  --issue 197 \
  --api-base https://github.boschdevcloud.com/api/v3 \
  --output issue-197.pdf \
  --css-style assets/markdown-dark.css

🎨 Styling

Use any CSS file to define the appearance of the resulting PDFs.

Example styles:

  • assets/markdown-dark.css – GitHub Dark Theme
  • assets/minimal.css – Simple light theme
  • assets/bosch.css – Bosch Corporate Design (experimental)

🖼️ Logo (optional)

Add a logo at the top of the PDF with --logo path/to/logo.png.

📦 CLI Overview

The docskin CLI provides the following commands:

  • setup Installs all required Python and system dependencies for docskin, including WeasyPrint and its Linux libraries. Example:

    docskin setup
    
  • md Converts a single Markdown file to a styled PDF. Uses the MarkdownHTMLExtractor for parsing, StyleManager for HTML/CSS rendering, and WeasyPrint for PDF export. Example:

    docskin md --input README.md --output README.pdf --css-style assets/minimal.css
    
  • md-dir Recursively converts all Markdown files in a directory (and subdirectories) to PDFs, preserving the folder structure. Example:

    docskin md-dir --input ./docs --output ./pdfs --css-style assets/markdown-dark.css
    
  • github Fetches a GitHub issue and converts it to a styled PDF. Supports custom API endpoints and authentication for private repos. Example:

    docskin github --repo owner/repo --issue 42 --output issue-42.pdf --css-style assets/markdown-dark.css
    

💡 Notes

  • GitHub APIs use .netrc for authentication (if private repos).
  • For Bosch internal: Use --api-base https://github.boschdevcloud.com/api/v3

📜 License and Third-Party Software

docskin is licensed under the MIT License – see LICENSE.txt for details.

This software uses WeasyPrint for PDF rendering.
WeasyPrint is licensed under the BSD 3-Clause License, and depends on system libraries such as Cairo, Pango, HarfBuzz, GDK-Pixbuf, and GLib, which are licensed under the LGPL or MIT licenses.

Some CSS files in assets/ are adapted from
sindresorhus/github-markdown-css,
which is licensed under the MIT License.

The file assets/github.svg.png is adapted from Primer Octicons, which is licensed under the MIT License.

The full license texts for docskin and the bundled third-party components are included in the LICENSE.txt file in this repository.

�️ Updated File Structure

docskin/
├── cli.py                # CLI entry point (Click commands: setup, md, md-dir, github)
├── converter.py          # MarkdownHTMLExtractor, MarkdownPdfRenderer, orchestration
├── github_api.py         # GitHub issue fetching
├── styles.py             # StyleManager: CSS loading & HTML rendering
├── setup.py              # Dependency installation logic
assets/
├── markdown-dark.css     # GitHub Dark Theme CSS [3rd party](https://github.com/sindresorhus/github-markdown-css)
├── markdown-light.css    # GitHub Light Theme CSS [3rd party](https://github.com/sindresorhus/github-markdown-css)
├── minimal.css           # Minimal light theme CSS
tests/
├── resources/
│   ├── markdown/         # Test Markdown files
├── test_cli.py           # CLI integration tests

Architecture

The architecture of docskin is designed to be modular and extensible. The main components are:

docskin architecture

  • CLI: The command-line interface for user interaction.
  • MarkdownHTMLExtractor: Extracts HTML from Markdown files.
  • StyleManager: Manages CSS styles and applies them to the HTML.
  • PDFExporter: Handles the conversion of styled HTML to PDF.
  • GitHubIssueFetcher: Fetches GitHub issues for conversion.

🧜 Mermaid Diagram Support

docskin automatically renders Mermaid diagrams embedded in Markdown files. Write standard fenced code blocks tagged mermaid and the diagrams will appear as crisp SVG graphics in the output PDF:

```mermaid
graph TD
    A[Start] --> B{Decision}
    B -->|Yes| C[Do it]
    B -->|No| D[Skip it]
```

Supported diagram types include flowcharts, sequence diagrams, class diagrams, Gantt charts, and all other types supported by the mermaid.ink rendering service.

Note: Diagram rendering requires an internet connection to reach https://mermaid.ink. When the service is unreachable the diagram source is preserved as a plain-text <pre> block so the rest of the document still renders correctly.

🛠️ TODO / Ideas

  • PDF metadata (author, title, etc.)
  • Generate TOC
  • Bundle multiple issues
  • Integrate Highlight.js

Made with ❤️ by a senior engineer passionate about open source.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docskin-0.3.1.tar.gz (77.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docskin-0.3.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file docskin-0.3.1.tar.gz.

File metadata

  • Download URL: docskin-0.3.1.tar.gz
  • Upload date:
  • Size: 77.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for docskin-0.3.1.tar.gz
Algorithm Hash digest
SHA256 a872ccbd38f83fe69a6be3b889624d07334ce0533eba35fbb0f2414cb4c0e9ac
MD5 fa910c2bd6d0d0488d68fe6a05a909ef
BLAKE2b-256 547519aa02ae22724c51a6ec3ab28b359cd8b882ecfe136a23e87f259e6cc5a0

See more details on using hashes here.

File details

Details for the file docskin-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: docskin-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for docskin-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 842b0f8f4c55f026e89aae6b49da5a736e4bd5ad639e08341ccd9851d8d22cf4
MD5 d3daebccc17def8bd7e6e7b4f451cc84
BLAKE2b-256 583c83b5079ed601ab7f28d2073e22a1f4bc767017bfe3187ee9a78381654595

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page