|
| 1 | +# Contribute to the Polkadot Docs |
| 2 | + |
| 3 | +> **📋 Essential**: All contributions must follow the [PaperMoon Style Guide](https://github.com/papermoonio/documentation-style-guide). |
| 4 | +
|
| 5 | +## Contents |
| 6 | + |
| 7 | +- [Quick Start](#quick-start) |
| 8 | +- [Edit Online with GitHub (Simple Changes)](#edit-online-with-github-simple-changes) |
| 9 | +- [Fork and Edit Locally](#fork-and-edit-locally) |
| 10 | + - [Fix or Improve Existing Content](#fix-or-improve-existing-content) |
| 11 | + - [Add a New Page](#add-a-new-page) |
| 12 | + - [Create a New Section](#create-a-new-section) |
| 13 | + - [Write a Tutorial](#write-a-tutorial) |
| 14 | + - [Working with Content Elements](#working-with-content-elements) |
| 15 | + - [Adding Images](#adding-images) |
| 16 | + - [Using Code Snippets](#using-code-snippets) |
| 17 | + - [Adding Callout Boxes](#adding-callout-boxes) |
| 18 | + |
| 19 | +## Quick Start |
| 20 | + |
| 21 | +There are two main ways to contribute: |
| 22 | + |
| 23 | +- **[Edit Online with GitHub](#edit-online-with-github-simple-changes)** |
| 24 | + - Best for simple text changes like fixing typos or making small updates directly in your browser. |
| 25 | + |
| 26 | +- **[Fork and Edit Locally](#fork-and-edit-locally)** |
| 27 | + - Recommended for more complex contributions that require local testing or previewing changes. |
| 28 | + |
| 29 | + |
| 30 | +## Edit Online with GitHub (Simple Changes) |
| 31 | + |
| 32 | +For simple contributions like fixing typos or making small text changes, you can use GitHub's online editor. |
| 33 | + |
| 34 | +### Making Your Changes |
| 35 | + |
| 36 | +1. Navigate to the file you want to edit on GitHub. |
| 37 | +2. Click the pencil icon (✏️) to edit the file. |
| 38 | +3. Make your changes in the online editor. |
| 39 | +4. Follow the [PaperMoon Style Guide](https://github.com/papermoonio/documentation-style-guide). |
| 40 | + |
| 41 | +### Creating Your Pull Request |
| 42 | + |
| 43 | +1. Scroll to **Propose changes** at the bottom of the editor. |
| 44 | +2. Add a descriptive commit message explaining your changes. |
| 45 | +3. Click **Propose changes**. GitHub will automatically: |
| 46 | + - Fork the repository to your account. |
| 47 | + - Create a branch with your changes. |
| 48 | + - Open a pull request. |
| 49 | + - Make sure to check **Allow edits from maintainers**. |
| 50 | + |
| 51 | +## Fork and Edit Locally |
| 52 | + |
| 53 | +For more complex contributions, which involve rendering (e.g., adding a `.nav.yml` section, code snippets, etc) or when you want to preview changes locally. |
| 54 | + |
| 55 | +### Initial Setup |
| 56 | + |
| 57 | +Before making contributions, you need to set up the proper directory structure for local development: |
| 58 | + |
| 59 | +1. Clone the MkDocs repository: |
| 60 | + |
| 61 | + > **polkadot-mkdocs**: Contains the "engine" (MkDocs configuration, theme, styling) |
| 62 | +
|
| 63 | + ```bash |
| 64 | + git clone https://github.com/papermoonio/polkadot-mkdocs.git |
| 65 | + cd polkadot-mkdocs |
| 66 | + ``` |
| 67 | + |
| 68 | +2. Fork and clone the docs repository inside polkadot-mkdocs: |
| 69 | + |
| 70 | + > **polkadot-docs**: Contains the "content" (documentation pages, tutorials, images) |
| 71 | +
|
| 72 | + ```bash |
| 73 | + # Fork polkadot-docs on GitHub first, then: |
| 74 | + git clone https://github.com/YOUR_USERNAME/polkadot-docs.git |
| 75 | + cd polkadot-docs |
| 76 | + git checkout -b YOUR_FEATURE_BRANCH |
| 77 | + ``` |
| 78 | + |
| 79 | + Your directory structure should now look like: |
| 80 | + ``` |
| 81 | + polkadot-mkdocs/ |
| 82 | + ├── polkadot-docs/ # Your forked repository |
| 83 | + ├── material-overrides/ |
| 84 | + └── mkdocs.yml |
| 85 | + ``` |
| 86 | + |
| 87 | +### Making Changes |
| 88 | + |
| 89 | +1. Make your changes: |
| 90 | + |
| 91 | + - Follow the [PaperMoon Style Guide](https://github.com/papermoonio/documentation-style-guide). |
| 92 | + - Test your changes locally (see [Run Polkadot Docs Locally](../README.md#run-polkadot-docs-locally)). |
| 93 | + |
| 94 | +2. Update AI documentation: |
| 95 | + |
| 96 | + After making content changes, regenerate the AI-ready documentation files. |
| 97 | + |
| 98 | + Set up your Python environment following the [Set Up Python Environment](./README.md#set-up-python-environment) section of the README, then run: |
| 99 | + ```bash |
| 100 | + python3 scripts/generate_llms.py |
| 101 | + ``` |
| 102 | + **Note**: Run this script on every PR once all changes are committed. |
| 103 | + |
| 104 | +3. Create pull request: |
| 105 | + |
| 106 | + - Push your branch and create a pull request. |
| 107 | + - Use the PR template to indicate your review preference. |
| 108 | + |
| 109 | +## Fix or Improve Existing Content |
| 110 | + |
| 111 | +Making changes to existing pages is the simplest contribution: |
| 112 | + |
| 113 | +1. **Edit the content**: Make your improvements directly to the existing markdown file. |
| 114 | +2. **Follow style guide**: Ensure your changes maintain proper formatting according to the [PaperMoon Documentation Style Guide](https://github.com/papermoonio/documentation-style-guide). |
| 115 | +3. **Test locally**: Verify your changes render correctly by running the Polkadot docs locally. Instructions can be found in the [README](./README.md#run-polkadot-docs-locally) |
| 116 | + |
| 117 | +## Add a New Page |
| 118 | + |
| 119 | +**Requirement**: Follow the [PaperMoon Documentation Style Guide](https://github.com/papermoonio/documentation-style-guide). |
| 120 | + |
| 121 | +To add a page to an existing section: |
| 122 | + |
| 123 | +1. Create your markdown file following [naming conventions](https://github.com/papermoonio/documentation-style-guide/blob/main/style-guide.md#naming-conventions). |
| 124 | + |
| 125 | +2. Include required frontmatter: |
| 126 | + |
| 127 | + ```markdown |
| 128 | + --- |
| 129 | + title: Page Title (max 60 chars for SEO) |
| 130 | + description: Description for SEO (120-160 chars). |
| 131 | + categories: Category1, Category2 |
| 132 | + --- |
| 133 | + |
| 134 | + # Page Title |
| 135 | + |
| 136 | + ## Introduction |
| 137 | + |
| 138 | + Write 2-3 paragraphs to introduce the topic. |
| 139 | + |
| 140 | + ## Prerequisites |
| 141 | + |
| 142 | + List any required tools, knowledge, or setup. |
| 143 | + ``` |
| 144 | + |
| 145 | + **Categories** |
| 146 | + |
| 147 | + Available categories for pages are found in [scripts/llms_config.json](./scripts/llms_config.json). |
| 148 | + |
| 149 | + **Search Engine Optimization (SEO)** |
| 150 | + |
| 151 | + Resources for good SEO: |
| 152 | + - [Google's title recommendations](https://developers.google.com/search/docs/advanced/appearance/title-link?hl=en) |
| 153 | + - [Google's description recommendations](https://developers.google.com/search/docs/advanced/appearance/snippet?hl=en) |
| 154 | + |
| 155 | +3. Add your page to the `.nav.yml` file in the same directory: |
| 156 | + |
| 157 | + ```yaml |
| 158 | + - 'Your Page Display Name': 'your-file-name.md' |
| 159 | + ``` |
| 160 | +
|
| 161 | +## Create a New Section |
| 162 | +
|
| 163 | +To create an entirely new section of documentation: |
| 164 | +
|
| 165 | +1. Create directory structure: |
| 166 | +
|
| 167 | + ``` |
| 168 | + your-new-section/ |
| 169 | + ├── .nav.yml |
| 170 | + ├── index.md |
| 171 | + └── your-first-page.md |
| 172 | + ``` |
| 173 | + |
| 174 | +2. Create `.nav.yml`: |
| 175 | + |
| 176 | + ```yaml |
| 177 | + title: Section Display Name |
| 178 | + nav: |
| 179 | + - index.md |
| 180 | + - 'Page Display Name': 'file-name.md' |
| 181 | + - subdirectory-name |
| 182 | + ``` |
| 183 | + |
| 184 | + - **`title`**: Displayed in left navigation |
| 185 | + - **`index.md`**: Always first in nav list |
| 186 | + - **Files**: `'Display Name': 'file-name.md'` |
| 187 | + - **Subdirectories**: Listed by directory name |
| 188 | + |
| 189 | +3. Create the `index.md` landing page with frontmatter and content introducing the section. |
| 190 | + |
| 191 | + - In the `index.md` add the following snippet to display what content is available in the section: |
| 192 | + ```markdown |
| 193 | + ## In This Section |
| 194 | +
|
| 195 | + :::INSERT_IN_THIS_SECTION::: |
| 196 | + ``` |
| 197 | + |
| 198 | +## Write a Tutorial |
| 199 | + |
| 200 | +This section covers tutorial-specific requirements and formatting. |
| 201 | + |
| 202 | +**Requirement**: Follow the [PaperMoon Documentation Style Guide](https://github.com/papermoonio/documentation-style-guide). |
| 203 | + |
| 204 | +### Choose Your Tutorial Section |
| 205 | +``` |
| 206 | +tutorials/ |
| 207 | +├── dapps/ # Application development guides |
| 208 | +├── interoperability/ # XCM, cross-chain operations |
| 209 | +├── onchain-governance/ # Governance operations |
| 210 | +├── polkadot-sdk/ # SDK-based development |
| 211 | +└── smart-contracts/ # Smart contract development |
| 212 | +``` |
| 213 | +
|
| 214 | +### Set Up Directory Structure |
| 215 | +
|
| 216 | +``` |
| 217 | +tutorials/<section>/<subsection>/<tutorial-name>.md |
| 218 | +images/tutorials/<section>/<subsection>/<tutorial-name>/ |
| 219 | +.snippets/code/tutorials/<section>/<subsection>/<tutorial-name>/ |
| 220 | +``` |
| 221 | +
|
| 222 | +### Use the Tutorial Template |
| 223 | +
|
| 224 | +```markdown |
| 225 | +--- |
| 226 | +title: Tutorial Title (max 60 chars) |
| 227 | +description: Description 120-160 chars. |
| 228 | +tutorial_badge: Beginner | Intermediate | Advanced |
| 229 | +categories: Category1, Category2 |
| 230 | +--- |
| 231 | +
|
| 232 | +# Tutorial Title |
| 233 | +
|
| 234 | +## Introduction |
| 235 | +
|
| 236 | +Brief explanation of what users will learn/build |
| 237 | +
|
| 238 | +## Prerequisites |
| 239 | +
|
| 240 | +Required knowledge/tools |
| 241 | +
|
| 242 | +## [Action-Oriented Section Title] |
| 243 | +
|
| 244 | +Instructions with commands |
| 245 | +
|
| 246 | +## Verification |
| 247 | +
|
| 248 | +How to confirm it worked |
| 249 | +
|
| 250 | +## Where to Go Next |
| 251 | +
|
| 252 | +Related tutorials |
| 253 | +``` |
| 254 | + |
| 255 | +### Tutorial Requirements |
| 256 | + |
| 257 | +- All code examples must be tested and functional. |
| 258 | +- Always specify dependency versions (e.g., `npm install [email protected]`). |
| 259 | +- Use action-oriented section titles. |
| 260 | +- Include verification steps. |
| 261 | + |
| 262 | +## Working with Content Elements |
| 263 | + |
| 264 | +### Adding Images |
| 265 | + |
| 266 | +**Where to store**: `images/<path-matching-doc-structure>/` |
| 267 | + |
| 268 | +**Requirements**: |
| 269 | + |
| 270 | +- **Format**: `.webp` |
| 271 | +- **Desktop screenshots**: 1512px width, variable height |
| 272 | +- **Browser extension screenshots**: 400x600px |
| 273 | + |
| 274 | +**How to use**: |
| 275 | + |
| 276 | +```markdown |
| 277 | + |
| 278 | +``` |
| 279 | + |
| 280 | +**Adding annotations**: |
| 281 | + |
| 282 | +Use assets from the [.assets/annotations](.assets/annotations/) directory: |
| 283 | +- **Arrows**: Highlight single elements |
| 284 | +- **Steps**: Highlight multiple elements (use numbers for numbered lists, letters for alphabetical lists) |
| 285 | + |
| 286 | +### Using Code Snippets |
| 287 | + |
| 288 | +**Purpose**: For any code used on the page or for reuse of text across multiple pages while maintaining it in one place. |
| 289 | + |
| 290 | +**Where to store**: `.snippets/code/<path-matching-doc-structure>/<snippet-name>` |
| 291 | + |
| 292 | +**How to use**: |
| 293 | +```javascript |
| 294 | +--8<-- 'code/<subdirectory>/<snippet-file-name>.js:10:20' |
| 295 | +``` |
| 296 | + |
| 297 | +**File types**: |
| 298 | +- **Text snippets**: `.md` files for reusable copy |
| 299 | +- **Code snippets**: Use appropriate language extension (`.js`, `.py`, etc.) |
| 300 | + |
| 301 | +Learn more about [snippets syntax](https://facelessuser.github.io/pymdown-extensions/extensions/snippets/). |
| 302 | + |
| 303 | +### Adding Callout Boxes |
| 304 | + |
| 305 | +Use these to highlight important information: |
| 306 | + |
| 307 | +```markdown |
| 308 | +!!!tip |
| 309 | + Helpful tips and shortcuts. |
| 310 | + |
| 311 | +!!!note |
| 312 | + Important information to remember. |
| 313 | + |
| 314 | +!!!warning |
| 315 | + Potential issues or caveats. |
| 316 | +``` |
| 317 | + |
| 318 | +### Using Termynal for Command Output |
| 319 | + |
| 320 | +**Purpose**: Display terminal/command output in a visual format that simulates a terminal session. |
| 321 | + |
| 322 | +**When to use**: Anytime you need to show command output or terminal interactions in the documentation. |
| 323 | + |
| 324 | +**Basic syntax**: |
| 325 | + |
| 326 | +```html |
| 327 | +<div class="termynal" data-termynal> |
| 328 | + <span data-ty="input"><span class="file-path"></span>your-command-here</span> |
| 329 | + <span data-ty="progress"></span> |
| 330 | + <span data-ty>Output line 1</span> |
| 331 | + <span data-ty>Output line 2</span> |
| 332 | +</div> |
| 333 | +``` |
0 commit comments