Skip to content

cathaysia/asphinx

Repository files navigation

Asphinx

A modern AsciiDoc static site generator designed for technical documentation and books.

Features

  • πŸš€ High Performance: Built with Rust, supports concurrent processing
  • πŸ“š AsciiDoc Support: Full AsciiDoc format support including mathematical formulas and diagrams
  • 🎨 Modern Theme: Responsive theme based on React + Tailwind CSS
  • πŸ” Full-text Search: Built-in search functionality for quick content discovery
  • πŸ“Š Diagram Support: Supports multiple diagram formats (PlantUML, Mermaid, Graphviz, etc.)
  • ⚑ Fast Build: Smart caching and incremental builds
  • 🌐 SEO Friendly: Generates optimized HTML structure

Installation

Build from Source

git clone https://github.com/your-username/asphinx.git
cd asphinx
cargo build --release

System Requirements

  • Rust 1.70+
  • Node.js 18+ (for theme building)
  • AsciiDoctor (for document processing)

Quick Start

  1. Initialize project structure:

    your-project/
    β”œβ”€β”€ content/
    β”‚   β”œβ”€β”€ index.adoc
    β”‚   β”œβ”€β”€ book1/
    β”‚   β”‚   β”œβ”€β”€ index.adoc
    β”‚   β”‚   β”œβ”€β”€ ch1.adoc
    β”‚   β”‚   └── ch2.adoc
    β”‚   └── book2/
    β”‚       β”œβ”€β”€ index.adoc
    β”‚       β”œβ”€β”€ ch1.adoc
    β”‚       └── ch2.adoc
    β”œβ”€β”€ theme/
    └── asphinx.toml
    
  2. Create your main index file (content/index.adoc):

    = My Documentation
    
    Welcome to my documentation site.
    
    - xref:book1/index.adoc[Book 1]
    - xref:book2/index.adoc[Book 2]
  3. Configure Asphinx (asphinx.toml):

    [asciidoc]
    extensions = ["asciidoctor-mathematical", "asciidoctor-diagram"]
    
    [asciidoc.attributes]
    icons = "font"
    toc = 1
    experimental = ""
    source-highlighter = "pygments"
  4. Build the theme:

    cd theme
    npm install
    npm run build
  5. Generate the site:

    ./target/release/asphinx --theme theme

Usage

Command Line Options

asphinx [OPTIONS] --theme <THEME>

Options:
      --minify         Enable HTML minification
      --theme <THEME>  Path to the theme directory
  -h, --help           Print help

Configuration

The asphinx.toml file contains the configuration for your site:

# Default configuration
no_default = false

[asciidoc]
extensions = ["asciidoctor-mathematical", "asciidoctor-diagram"]

[asciidoc.attributes]
icons = "font"
toc = 1
experimental = ""
source-highlighter = "pygments"
# Diagram formats
plantuml-format = "svg"
mermaid-format = "svg"
graphviz-format = "svg"
# ... more diagram formats

Supported Diagram Types

Asphinx supports a wide variety of diagram formats:

  • PlantUML: Sequence diagrams, class diagrams, activity diagrams
  • Mermaid: Flowcharts, sequence diagrams, Gantt charts
  • Graphviz: DOT language graphs
  • Ditaa: ASCII art diagrams
  • BlockDiag: Block diagrams
  • SeqDiag: Sequence diagrams
  • ActDiag: Activity diagrams
  • NwDiag: Network diagrams
  • And many more...

Theme Development

The theme is built with modern web technologies:

  • React 18: Component-based UI
  • TypeScript: Type-safe development
  • Tailwind CSS: Utility-first CSS framework
  • Vite: Fast build tool
  • Radix UI: Accessible component primitives

Theme Structure

theme/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.tsx          # Main React entry point
β”‚   β”œβ”€β”€ search-bar.tsx    # Search functionality
β”‚   β”œβ”€β”€ style.css         # Global styles
β”‚   └── components/       # UI components
β”œβ”€β”€ layouts/
β”‚   └── page.html         # HTML template
└── assets/               # Static assets

Customizing the Theme

  1. Modify the React components in theme/src/
  2. Update styles in theme/src/style.css
  3. Rebuild the theme: npm run build

Project Structure

asphinx/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.rs           # Main application entry
β”‚   β”œβ”€β”€ config.rs         # Configuration handling
β”‚   β”œβ”€β”€ generator.rs      # HTML generation logic
β”‚   β”œβ”€β”€ index.rs          # Search index management
β”‚   └── utils/            # Utility modules
β”œβ”€β”€ content/              # Example content
β”œβ”€β”€ theme/                # Default theme
└── asphinx.toml          # Default configuration

Development

Building

cargo build

Running Tests

cargo test

Acknowledgments

About

sphinx for asciidoc

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •