Modern documentation system for Substrate API Sidecar with enhanced user experience.
The documentation system is built with vanilla JavaScript and webpack, creating a self-contained deployment that works without a server.
- main.js - Application orchestration and navigation
- parser.js - OpenAPI specification processing
- components.js - UI rendering and DOM manipulation
- api-explorer.js - Interactive "try it out" functionality
- search.js - Real-time search across endpoints
- guides-content.js - Static guide content management
Uses webpack to bundle all assets into a single deployable dist/ folder containing:
index.html- Complete documentation pagebundle.js- All JavaScript with embedded OpenAPI specfavicon.ico- Site icon
- Create a markdown file in
guides/directory - Import it in
scripts/guides-content.js:import newGuideMd from '../guides/NEW_GUIDE.md';
- Add to the exports:
export const GUIDES_CONTENT = { 'new-guide': convertMarkdownToHtml(newGuideMd) }; export const GUIDE_METADATA = { 'new-guide': { title: 'New Guide Title', description: 'Guide description' } };
- Add navigation link in
index.html:<li class="nav-item"> <a href="#guide-new-guide" class="nav-link" data-guide="new-guide"> <span>New Guide</span> </a> </li>
- Add content section in
index.html:<section id="guide-new-guide" class="content-section" style="display: none;"> <div class="section-header"> <h1>New Guide Title</h1> </div> <div class="guide-content"> <p class="lead">Guide description</p> </div> </section>
Follow the same pattern as guides, but use:
data-specattribute instead ofdata-guide#spec-prefix for IDs and URLs- Add to specifications navigation section
The markdown converter supports:
- Headers (h1-h4) with automatic ID generation
- Tables with proper HTML conversion
- Code blocks with syntax highlighting
- Internal links with smooth scrolling
- Bold, italic, and inline code formatting
- Notice boxes and blockquotes
cd docs-v2
yarn install
yarn dev # Development server on localhost:8082yarn build # Creates deployable dist/ folderThe built dist/ folder is completely self-contained and can be:
- Opened directly in a browser
- Served by any web server
- Deployed to static hosting services
Default servers are configured in index.html:
<select id="server-select">
<option value="0">Polkadot Public</option>
<option value="1" selected>Localhost</option>
</select>The documentation uses CSS custom properties for theming. Modify styles/main.css to change colors and spacing.
The OpenAPI specification is embedded during build process. To update:
- Replace
openapi-v1.yamlwith new specification - Run
yarn build - Deploy the new
dist/folder
No code changes required - the system automatically processes the new specification.