@@ -54,7 +54,7 @@ pnpm dev
54544 . After making changes run the lint command to make formatting rules are applied
5555
5656``` bash
57- pnpm run check:fix
57+ pnpm run check
5858```
5959
6060## Project Structure
@@ -114,7 +114,7 @@ The application follows Next.js 13+ app directory structure:
114114
115115### Configuration Files
116116
117- - ` source.config.ts ` - Fumadocs MDX configuration with math, mermaid, and code highlighting support
117+ - ` source.config.ts ` - [ Fumadocs] ( https://fumadocs.dev ) MDX configuration with math, mermaid, and code highlighting support
118118- ` next.config.mjs ` - Next.js configuration
119119- ` postcss.config.mjs ` - PostCSS configuration for styling
120120- ` tsconfig.json ` - TypeScript configuration
@@ -245,7 +245,7 @@ To add or modify navigation:
245245- Receives the navigation tree from ` useNavigationTree ` hook
246246
247247** DocsLayout** (` src/components/layout/docs.tsx ` )
248- - Base documentation layout component from Fumadocs
248+ - Base documentation layout component from [ Fumadocs] ( https://fumadocs.dev )
249249- Renders the sidebar, navigation, and page content
250250- Configured with navigation tree and tab information
251251
@@ -271,11 +271,311 @@ Product-specific icons located in `src/components/icons/`:
271271
272272Icons are React components that accept className props for styling.
273273
274+ ## Documentation Framework
275+
276+ This project is built on [ Fumadocs] ( https://fumadocs.dev ) , a modern documentation framework that provides:
277+
278+ - ** MDX Support** : Write documentation in MDX with React components
279+ - ** Built-in Search** : Full-text search powered by Algolia
280+ - ** OpenAPI Integration** : Automatic API reference generation from OpenAPI specs
281+ - ** Type-safe Content** : TypeScript integration for content and navigation
282+ - ** Theme Support** : Built-in light/dark mode with customizable themes
283+
284+ Fumadocs handles the core infrastructure, allowing us to focus on content and customization. For detailed framework documentation, visit [ fumadocs.dev] ( https://fumadocs.dev ) .
285+
286+ ## Automation Scripts
287+
288+ The repository includes several automation scripts in the ` scripts/ ` directory to help maintain documentation quality and automate repetitive tasks.
289+
290+ ### API Documentation Generation
291+
292+ ** Script** : ` scripts/generate-api-docs.js `
293+
294+ This script automates the generation of Solidity API reference documentation from OpenZeppelin contract repositories using Solidity Docgen.
295+
296+ ** How it works:**
297+
298+ 1 . Clones a specified contracts repository (with branch selection)
299+ 2 . Installs dependencies and runs the ` npm run prepare-docs ` command
300+ 3 . Copies generated markdown files from the ` docs/modules/api/pages ` directory
301+ 4 . Copies example files from ` docs/modules/api/examples ` if available
302+ 5 . Places the generated documentation in the specified output directory
303+ 6 . Cleans up temporary files
304+
305+ ** Usage:**
306+
307+ ``` bash
308+ node scripts/generate-api-docs.js \
309+ --repo https://github.com/OpenZeppelin/openzeppelin-contracts.git \
310+ --branch master \
311+ --api-output content/contracts/5.x/api \
312+ --examples-output examples
313+ ```
314+
315+ ** Options:**
316+
317+ - ` --repo, -r ` - Contracts repository URL
318+ - ` --branch, -b ` - Branch to clone (default: master)
319+ - ` --temp-dir, -t ` - Temporary directory for cloning (default: temp-contracts)
320+ - ` --api-output, -a ` - API documentation output directory
321+ - ` --examples-output, -e ` - Examples output directory
322+ - ` --help, -h ` - Show help message
323+
324+ ** Requirements:**
325+
326+ The target repository must have:
327+ - A ` docs/config-md.js ` file (Solidity Docgen configuration)
328+ - A ` docs/templates-md/ ` directory (markdown templates)
329+ - An ` npm run prepare-docs ` script that generates documentation
330+
331+ See the [ README] ( README.md#solidity-docgen ) for instructions on setting up a repository for API generation.
332+
333+ ### OpenAPI Documentation
334+
335+ ** File** : ` src/lib/openapi.ts `
336+
337+ This file configures OpenAPI specification integration using Fumadocs OpenAPI server utilities.
338+
339+ ** How it works:**
340+
341+ The ` openapi.ts ` file creates an OpenAPI instance that:
342+ 1 . Fetches OpenAPI spec files from remote URLs (e.g., GitHub raw URLs)
343+ 2 . Parses the specifications
344+ 3 . Makes them available to Fumadocs for automatic API documentation generation
345+
346+ ** Current configuration:**
347+
348+ ``` typescript
349+ export const openapi = createOpenAPI ({
350+ input: [
351+ " https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-relayer/refs/heads/main/openapi.json" ,
352+ ],
353+ });
354+ ```
355+
356+ ** Adding new OpenAPI specs:**
357+
358+ To add documentation for a new API, add the URL to the ` input ` array:
359+
360+ ``` typescript
361+ export const openapi = createOpenAPI ({
362+ input: [
363+ " https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-relayer/refs/heads/main/openapi.json" ,
364+ " https://raw.githubusercontent.com/YourOrg/your-api/main/openapi.json" ,
365+ ],
366+ });
367+ ```
368+
369+ The OpenAPI documentation is automatically rendered in MDX files using Fumadocs transformers configured in ` source.config.ts ` .
370+
371+ ### Changelog Generation
372+
373+ ** Script** : ` scripts/generate-changelog.js `
374+
375+ This script automatically generates changelog documentation from GitHub releases using the ` changelog-from-release ` tool.
376+
377+ ** How it works:**
378+
379+ 1 . Uses the ` changelog-from-release ` CLI tool to fetch GitHub releases
380+ 2 . Formats the release notes as markdown
381+ 3 . Adds MDX frontmatter with title metadata
382+ 4 . Removes the tool's generated tag
383+ 5 . Writes the formatted changelog to ` changelog.mdx `
384+
385+ ** Usage:**
386+
387+ ``` bash
388+ node scripts/generate-changelog.js < repo_url> < output_directory>
389+ ```
390+
391+ ** Example:**
392+
393+ ``` bash
394+ node scripts/generate-changelog.js \
395+ OpenZeppelin/openzeppelin-relayer \
396+ content/relayer/1.2.x
397+ ```
398+
399+ This generates ` content/relayer/1.2.x/changelog.mdx ` with all releases from the repository.
400+
401+ ** Requirements:**
402+
403+ Install ` changelog-from-release ` :
404+ ``` bash
405+ # macOS
406+ brew install changelog-from-release
407+
408+ # Or download from: https://github.com/rhysd/changelog-from-release
409+ ```
410+
411+ ** Output format:**
412+
413+ ``` mdx
414+ ---
415+ title: Changelog
416+ ---
417+
418+ # [ Version] - Date
419+
420+ Release notes content...
421+ ```
422+
423+ ### Link Validation
424+
425+ ** Script** : ` scripts/link-validation.ts `
426+
427+ A comprehensive link validation tool that checks all internal links in documentation files and navigation structures.
428+
429+ ** How it works:**
430+
431+ 1 . ** Scans all MDX files** in the ` content/ ` directory
432+ 2 . ** Extracts URLs** from markdown links and custom components (like ` Card ` components)
433+ 3 . ** Validates navigation trees** to ensure all URLs in JSON navigation files exist
434+ 4 . ** Checks fragments** (hash links) to ensure heading IDs exist on target pages
435+ 5 . ** Reports broken links** with file locations and line numbers
436+
437+ ** Usage:**
438+
439+ ``` bash
440+ # Check all links and print to console
441+ npx tsx scripts/link-validation.ts
442+
443+ # Check specific scope (e.g., only contracts documentation)
444+ npx tsx scripts/link-validation.ts --scope " /contracts/*"
445+
446+ # Output results to a file
447+ npx tsx scripts/link-validation.ts --output link-errors.txt
448+
449+ # Disable fragment checking
450+ npx tsx scripts/link-validation.ts --no-ignore-fragments
451+ ```
452+
453+ ** Options:**
454+
455+ - ` --scope <pattern> ` - Validate only files matching the pattern (supports wildcards)
456+ - ` --output <file> ` - Write results to a file instead of console
457+ - ` --no-ignore-fragments ` - Include fragment validation (hash links)
458+
459+ ** What it validates:**
460+
461+ 1 . ** File links** : All markdown links in ` .mdx ` files
462+ 2 . ** Component links** : ` href ` attributes in custom components like ` Card `
463+ 3 . ** Navigation URLs** : All URLs in navigation JSON files
464+ 4 . ** Fragment links** : Heading anchors (` #heading-id ` ) on pages
465+ 5 . ** Relative paths** : Relative file paths resolved as URLs
466+
467+ ** Example output:**
468+
469+ ```
470+ Invalid URLs in content/contracts/5.x/tokens.mdx:
471+ /contracts/invalid-page: URL not found in site pages at line 45 column 12
472+ /contracts/5.x/erc20#nonexistent-heading: Fragment '#nonexistent-heading' not found on page at line 78 column 5
473+ ------
474+
475+ Invalid URLs in Navigation Trees:
476+ Ethereum & EVM: /deprecated/old-page - URL not found in site pages
477+ ------
478+
479+ Summary: 3 errors found in 2 files out of 150 total files
480+ ```
481+
482+ ** When to run:**
483+
484+ - Before submitting a pull request
485+ - After adding or reorganizing documentation
486+ - After updating navigation structures
487+ - As part of CI/CD pipeline (recommended)
488+
489+ ### Search Content Synchronization
490+
491+ ** Script** : ` scripts/sync-search-content.ts `
492+ ** Workflow** : ` .github/workflows/sync-search.yml `
493+
494+ This script synchronizes documentation content with Algolia search indexes, enabling full-text search across the documentation.
495+
496+ ** How it works:**
497+
498+ 1 . ** Creates a temporary route** (` src/app/static.json/route.ts ` ) that exports search indexes
499+ 2 . ** Runs a Next.js build** to generate static search data at ` .next/server/app/static.json.body `
500+ 3 . ** Reads the generated search records** containing page metadata and content
501+ 4 . ** Syncs to Algolia** using the Fumadocs Algolia integration
502+ 5 . ** Cleans up temporary files** after completion
503+
504+ ** Search index structure:**
505+
506+ The script uses ` src/lib/export-search-indexes.ts ` to generate search records:
507+
508+ ``` typescript
509+ {
510+ _id : " /contracts/5.x/erc20" , // Page URL (unique ID)
511+ url : " /contracts/5.x/erc20" , // Page URL
512+ title : " ERC-20 Tokens" , // Page title
513+ description : " Guide to ERC-20..." , // Page description
514+ structured : { ... }, // Structured content for search
515+ extra_data : { ... } // Full page content
516+ }
517+ ```
518+
519+ ** Version filtering:**
520+
521+ The script automatically excludes old documentation versions from search to keep results focused on current content:
522+
523+ ``` typescript
524+ const excludedVersions = [" /3.x/" , " /4.x/" , " /1.0.0/" , " /0.1.0/" , ... ];
525+ ```
526+
527+ ** Manual usage:**
528+
529+ ``` bash
530+ # Sync search content to Algolia
531+ bun run scripts/sync-search-content.ts
532+ ```
533+
534+ ** Required environment variables:**
535+
536+ ``` bash
537+ NEXT_PUBLIC_ALGOLIA_ID=your-algolia-app-id
538+ ALGOLIA_PRIVATE_KEY=your-algolia-admin-api-key
539+ ```
540+
541+ ** Automated workflow:**
542+
543+ The ` .github/workflows/sync-search.yml ` workflow automatically runs on every push to the ` main ` branch:
544+
545+ ``` yaml
546+ on :
547+ push :
548+ branches : [main]
549+ ` ` `
550+
551+ **How Algolia search works:**
552+
553+ 1. **Indexing**: The sync script sends document records to Algolia's ` document` index
554+ 2. **Search UI** : Fumadocs provides a built-in search component that queries Algolia
555+ 3. **Real-time updates** : Search results are updated automatically when content changes
556+ 4. **Ranked results** : Algolia handles relevance ranking, typo tolerance, and result highlighting
557+
558+ **Configuration:**
559+
560+ Search behavior is configured through Fumadocs in `src/lib/source.ts` and the search component in the layout. Algolia handles :
561+ - Instant search with type-ahead
562+ - Fuzzy matching for typos
563+ - Result highlighting
564+ - Search analytics
565+
566+ **Troubleshooting:**
567+
568+ If search results are outdated :
569+ 1. Check if the GitHub workflow ran successfully
570+ 2. Verify environment variables are set in GitHub secrets
571+ 3. Manually run the sync script locally
572+ 4. Check Algolia dashboard for index status
573+
274574# # Content Features
275575
276576# ## MDX Enhancements
277577
278- The site uses Fumadocs with the following MDX enhancements:
578+ The site uses [ Fumadocs](https://fumadocs.dev) with the following MDX enhancements :
279579
280580- **Math Support**: LaTeX math rendering with KaTeX
281581- **Mermaid Diagrams**: Flowcharts and diagrams using Mermaid syntax
@@ -286,12 +586,14 @@ The site uses Fumadocs with the following MDX enhancements:
286586
287587**OpenZeppelin Wizard** - Embedded contract generation tool for creating Solidity smart contracts
288588
289- ** Code Examples** - Copy-to-clipboard functionality for code blocks
589+ **Code Examples** - Copy-to-clipboard functionality for code blocks powered by Fumadocs
290590
291591**Version Switching** - Multi-version documentation support with version-specific content
292592
293593**Responsive Design** - Mobile-optimized navigation and content rendering
294594
595+ For more information on Fumadocs features, see the [official documentation](https://fumadocs.dev/docs).
596+
295597# # Adding New Content
296598
297599# ## Adding a New Documentation Page
0 commit comments