Automated documentation pipeline for P2P Foundation using Docusaurus.
# Install dependencies
npm install
# Build documentation from sources
python3 build_docs.py
# Start dev server
npm run startDocumentation/ # Git repository root
├── sources/ # 📁 SOURCE OF TRUTH - Add your MD files here
│ ├── whitepaper.md # Whitepaper documentation
│ └── sdk.md # SDK documentation
│
├── docs.config.json # ⚙️ Configuration for all documentation
├── build_docs.py # 🔧 Build script
│
├── docs/ # Generated whitepaper docs (auto-generated)
├── sdk/ # Generated SDK docs (auto-generated)
├── sidebars/ # Generated sidebars (auto-generated)
├── docusaurus.config.ts # Generated config (auto-generated)
│
├── src/ # React components & styling
├── static/ # Static assets (images, etc.)
├── package.json # Node.js dependencies
│
└── .github/
└── workflows/
└── deploy.yml # CI/CD pipeline
Add a new .md file to the sources/ folder:
# **My Documentation Title**
Introduction text here.
# **1. First Chapter**
## **1.1 Subsection**
Content here...
# **2. Second Chapter**
More content...Important: Use # (H1) for main chapters and ## (H2) for subsections.
Edit docs.config.json and add your doc to the docs array:
{
"docs": [
{
"id": "mydoc",
"source": "sources/mydoc.md",
"outputDir": "mydoc",
"routeBasePath": "mydoc",
"navbarLabel": "My Doc",
"navbarPosition": "left",
"sidebarId": "mydocSidebar",
"extractImages": true,
"splitByHeading": 1,
"numberSections": true,
"generateTocLinks": true,
"skipSections": ["My Documentation Title"]
}
]
}python3 build_docs.pyThat's it! Your documentation will be available at /mydoc with a navbar link.
| Option | Type | Description |
|---|---|---|
id |
string | Unique identifier for the doc |
source |
string | Path to source markdown file |
outputDir |
string | Where to generate the doc files |
routeBasePath |
string | URL path (e.g., /sdk) |
navbarLabel |
string | Label shown in navbar |
navbarPosition |
string | left or right |
sidebarId |
string | Sidebar identifier |
extractImages |
boolean | Extract base64 images to files |
splitByHeading |
number | Split on heading level (1 = H1) |
numberSections |
boolean | Add number prefixes to files |
generateTocLinks |
boolean | Generate TOC links in sidebar |
skipSections |
array | Section titles to exclude |
# Build all documentation
python3 build_docs.py
# Clean and rebuild
python3 build_docs.py --clean
# Start development server
npm run start
# Build for production
npm run buildThe repository includes a GitHub Actions workflow (.github/workflows/deploy.yml) that:
-
On every push to
main:- Builds documentation from sources
- Builds the Docusaurus site
- Deploys to GitHub Pages
-
On pull requests:
- Builds and validates (no deployment)
- Go to your repo Settings → Pages
- Set Source to "GitHub Actions"
- Push to
mainbranch to trigger deployment
Use H1 (#) for main chapters:
# **0. Vision**
# **1. Getting Started**
# **2. API Reference**Use H2 (##) for subsections:
## **1.1 Installation**
## **1.2 Configuration**You can embed base64 images and they'll be automatically extracted:
![Description][image1]
[image1]: data:image/png;base64,iVBORw0KGgo...Standard markdown code blocks are supported:
```typescript
const client = new P2PClient({ apiKey: 'xxx' });
```Push to main branch - automatic deployment via GitHub Actions.
npm run build
# Deploy the `build/` folderConnect your GitHub repo, set build command to:
python3 build_docs.py && npm run build
© P2P Foundation