@hrefcl/apidoc - v4.0.5
    Preparing search index...

    ๐Ÿ”จ Local Development

    Complete guide for setting up a local development environment for APIDoc, contributing to the project, and customizing functionality.

    • Node.js: >= 20.0.0 (LTS recommended)
    • npm: >= 8.0.0 or yarn: >= 1.22.0
    • Git: For version control
    • Editor: VS Code recommended with TypeScript extensions
    # Clone the repository
    git clone https://github.com/hrefcl/apidoc.git
    cd apidoc

    # Install dependencies
    npm install

    # Verify installation
    npm run typecheck
    npm run test:lint
    apidoc/
    โ”œโ”€โ”€ bin/ # CLI executable
    โ”‚ โ””โ”€โ”€ apidoc # Main CLI script
    โ”œโ”€โ”€ lib/ # TypeScript source code
    โ”‚ โ”œโ”€โ”€ core/ # Core logic
    โ”‚ โ”‚ โ”œโ”€โ”€ parsers/ # Comment parsers
    โ”‚ โ”‚ โ”œโ”€โ”€ workers/ # Data processors
    โ”‚ โ”‚ โ”œโ”€โ”€ filters/ # Output filters
    โ”‚ โ”‚ โ”œโ”€โ”€ languages/ # Language support
    โ”‚ โ”‚ โ””โ”€โ”€ errors/ # Error classes
    โ”‚ โ”œโ”€โ”€ index.ts # Main library entry
    โ”‚ โ”œโ”€โ”€ reader.ts # File reading logic
    โ”‚ โ””โ”€โ”€ writer.ts # Output generation
    โ”œโ”€โ”€ template/ # HTML templates
    โ”‚ โ”œโ”€โ”€ src/ # TypeScript/CSS source
    โ”‚ โ”‚ โ”œโ”€โ”€ main.ts # Main JavaScript
    โ”‚ โ”‚ โ””โ”€โ”€ css/ # CSS styles
    โ”‚ โ””โ”€โ”€ index.html # Main template
    โ”œโ”€โ”€ example/ # Example API for testing
    โ”œโ”€โ”€ test/ # Test suite
    โ”œโ”€โ”€ md/ # Project documentation
    โ”œโ”€โ”€ dist/ # Compiled output
    โ””โ”€โ”€ tmp/ # Temporary build files
    โ”œโ”€โ”€ package.json          # npm configuration and scripts
    โ”œโ”€โ”€ tsconfig.json # TypeScript configuration
    โ”œโ”€โ”€ eslint.config.js # ESLint configuration
    โ”œโ”€โ”€ typedoc.json # TypeDoc configuration
    โ”œโ”€โ”€ .gitignore # Git ignored files
    โ””โ”€โ”€ .github/ # GitHub Actions workflows
    โ””โ”€โ”€ workflows/
    โ”œโ”€โ”€ test.yml # Automated tests
    โ””โ”€โ”€ release.yml # Release pipeline
    # TypeScript compilation
    npm run build # Compile TypeScript + Stencil
    npm run typecheck # Type checking only
    npm run dev # Watch mode for development

    # Documentation generation
    npm run build:example # Generate example documentation
    npm run docs # Generate TypeDoc documentation
    npm run docs:serve # Serve docs at http://localhost:3001

    # Template development
    npm run dev:template # Build example + server on port 8080
    npm run start # Serve generated documentation

    # Quality Assurance
    npm run test # Run test suite
    npm run test:lint # ESLint + spell check
    npm run test:fix # Auto-fix ESLint issues
    npm run pre-commit # Complete validation (types + lint + tests)

    # Container workflows
    npm run serve # Build, containerize and serve with auto-open
    npm run serve:stop # Stop container
    # CSS and styles
    npm run build:css # Compile CSS for production
    npm run build:css:dev # CSS for local development

    # Cleanup
    npm run clean # Clean build directories
    npm run clean:all # Complete cleanup + node_modules

    # Release
    npm run version:patch # Increment patch version
    npm run version:minor # Increment minor version
    npm run version:major # Increment major version
    # Run all tests
    npm run test

    # Specific tests
    npm test -- --grep "parser" # Only parser tests
    npm test -- --grep "MQTT" # Only MQTT tests
    npm test -- test/core/parser.test.js # Specific file

    # Coverage
    npm run test:coverage # Generate coverage report
    test/
    โ”œโ”€โ”€ core/ # Core tests
    โ”‚ โ”œโ”€โ”€ parsers/ # Parser tests
    โ”‚ โ”œโ”€โ”€ workers/ # Worker tests
    โ”‚ โ””โ”€โ”€ filters/ # Filter tests
    โ”œโ”€โ”€ integration/ # Integration tests
    โ”œโ”€โ”€ fixtures/ # Test data
    โ””โ”€โ”€ helpers/ # Testing utilities
    // test/core/parsers/api.test.js
    import { describe, it } from 'mocha';
    import { expect } from 'chai';
    import { parseApi } from '../../../lib/core/parsers/api.js';

    describe('API Parser', () => {
    it('should parse basic API definition', () => {
    const content = '{get} /users Get Users';
    const result = parseApi(content);

    expect(result).to.have.property('method', 'get');
    expect(result).to.have.property('url', '/users');
    expect(result).to.have.property('title', 'Get Users');
    });

    it('should handle complex URLs with parameters', () => {
    const content = '{post} /users/:id/posts Create User Post';
    const result = parseApi(content);

    expect(result.url).to.equal('/users/:id/posts');
    expect(result.method).to.equal('post');
    });
    });
    // lib/core/parsers/my-new-parser.ts
    export function parseMyNewTag(content: string): any {
    // 1. Define regex for parsing
    const regex = /^(.+?)\s+(.+)$/;
    const match = content.match(regex);

    if (!match) {
    throw new Error('Invalid format for @myNewTag');
    }

    // 2. Extract data
    const [, type, description] = match;

    // 3. Return normalized object
    return {
    type: type.trim(),
    description: description.trim()
    };
    }
    // lib/core/parsers/index.ts
    import { parseMyNewTag } from './my-new-parser.js';

    export const parsers = {
    // ... existing parsers
    mynew: parseMyNewTag
    };
    // test/core/parsers/my-new-parser.test.js
    describe('My New Parser', () => {
    it('should parse custom tag correctly', () => {
    const result = parseMyNewTag('string User description');

    expect(result.type).to.equal('string');
    expect(result.description).to.equal('User description');
    });
    });
    template/
    โ”œโ”€โ”€ src/
    โ”‚ โ”œโ”€โ”€ main.ts # Main JavaScript
    โ”‚ โ”œโ”€โ”€ css/
    โ”‚ โ”‚ โ”œโ”€โ”€ tailwind.css # TailwindCSS styles
    โ”‚ โ”‚ โ””โ”€โ”€ bootstrap.css # Bootstrap styles
    โ”‚ โ””โ”€โ”€ components/ # Stencil components
    โ”œโ”€โ”€ assets/ # Static assets
    โ”œโ”€โ”€ index.html # Main template
    โ””โ”€โ”€ stencil.config.ts # Stencil configuration
    // template/src/components/api-endpoint.tsx
    import { Component, Prop, h } from '@stencil/core';

    @Component({
    tag: 'api-endpoint',
    styleUrl: 'api-endpoint.css',
    shadow: true
    })
    export class ApiEndpoint {
    @Prop() method: string;
    @Prop() url: string;
    @Prop() title: string;

    render() {
    return (
    <div class={`endpoint endpoint-${this.method}`}>
    <span class="method">{this.method.toUpperCase()}</span>
    <span class="url">{this.url}</span>
    <span class="title">{this.title}</span>
    </div>
    );
    }
    }
    # Development with hot reload
    npm run dev:template

    # Production build
    npm run build:template
    # Fork the repository on GitHub
    git clone https://github.com/your-username/apidoc.git
    cd apidoc

    # Configure upstream
    git remote add upstream https://github.com/hrefcl/apidoc.git

    # Install dependencies
    npm install

    # Verify everything works
    npm run pre-commit
    # Create and switch to new branch
    git checkout -b feature/my-new-feature

    # Or for bugfix
    git checkout -b fix/fix-some-issue
    # Iterative development
    npm run dev # Watch mode
    npm run build:example # Test changes
    npm run test # Run tests

    # Continuous validation
    npm run typecheck # Check types
    npm run test:lint # Linting
    # Staging and commit
    git add .
    git commit -m "feat: add support for new parser"

    # Push to your fork
    git push origin feature/my-new-feature
    • Create PR from your fork to main repository
    • Ensure all CI checks pass
    • Describe changes and justification
    • Wait for review and feedback
    // .vscode/launch.json
    {
    "version": "0.2.0",
    "configurations": [
    {
    "name": "Debug APIDoc",
    "type": "node",
    "request": "launch",
    "program": "${workspaceFolder}/bin/apidoc",
    "args": [
    "-i", "example/",
    "-o", "tmp/debug/",
    "--debug"
    ],
    "env": {
    "NODE_ENV": "development"
    },
    "console": "integratedTerminal",
    "sourceMaps": true
    }
    ]
    }
    // lib/utils/logger.ts
    export const logger = {
    debug: (message: string, data?: any) => {
    if (process.env.NODE_ENV === 'development') {
    console.log(`[DEBUG] ${message}`, data || '');
    }
    },

    info: (message: string) => {
    console.log(`[INFO] ${message}`);
    },

    error: (message: string, error?: Error) => {
    console.error(`[ERROR] ${message}`, error || '');
    }
    };
    # Complete build
    npm run build

    # Verify build
    npm run test
    npm run typecheck

    # Local distribution test
    npm pack
    npm install -g ./apidoc-*.tgz
    // package.json
    {
    "scripts": {
    "release:patch": "npm version patch && npm publish",
    "release:minor": "npm version minor && npm publish",
    "release:major": "npm version major && npm publish"
    }
    }
    • TypeScript: Use strict types
    • ESLint: Follow project configuration
    • Commits: Use conventional commits
    • Tests: Maintain coverage > 80%
    • Documentation: Update docs for new features
    • [ ] Tests pass locally
    • [ ] TypeScript compiles without errors
    • [ ] ESLint has no warnings
    • [ ] Documentation updated
    • [ ] CHANGELOG.md updated
    • [ ] Examples working
    • ๐Ÿ› Bug fixes: Error corrections
    • โœจ Features: New functionality
    • ๐Ÿ“ Docs: Documentation improvements
    • ๐ŸŽจ Style: UI/UX improvements
    • โšก Performance: Optimizations
    • ๐Ÿ”ง Tooling: Development tools

    The APIDoc development environment is designed to be accessible and productive, enabling effective contributions to the project.