### Install and Serve MokaDocs CLI Source: https://github.com/jacobwi/moka.docs/blob/master/README.nuget.md Installs the MokaDocs command-line tool globally and starts the development server for live preview. This is the initial setup for using MokaDocs. ```bash dotnet tool install -g mokadocs mokadocs init mokadocs serve ``` -------------------------------- ### Documenting Library Usage Source: https://github.com/jacobwi/moka.docs/blob/master/docs/getting-started/quickstart.md Demonstrates how to include installation instructions and C# code examples within a Markdown documentation file. ```bash dotnet add package MyLibrary ``` ```csharp using MyLibrary; var result = MyClass.DoSomething("hello"); Console.WriteLine(result); ``` -------------------------------- ### Interactive REPL Examples for SampleLibrary Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/guide/getting-started.md Demonstrates interactive usage of SampleLibrary features within a REPL environment. Examples include calculator operations, processing with generic methods, working with shapes, and managing an observable list with event handling. ```csharp-repl // Create a calculator and perform operations var calc = new Calculator(); Console.WriteLine($"5 + 3 = {calc.Add(5, 3)}"); Console.WriteLine($"20 / 4 = {calc.Divide(20, 4)}"); // Use the generic Process method var doubled = calc.Process(7, x => x * 2); Console.WriteLine($"7 doubled = {doubled}"); ``` ```csharp-repl // Work with shapes var shapes = new IShape[] { new Circle(3.0), new Rectangle(4.0, 5.0) }; foreach (var shape in shapes) { Console.WriteLine($"{shape.Name}: area = {shape.CalculateArea():F2}"); } ``` ```csharp-repl // Observable list with events var names = new ObservableList(); names.ItemAdded += (_, name) => Console.WriteLine($" Welcome, {name}!"); Console.WriteLine("Adding members:"); names.Add("Alice"); names.Add("Bob"); Console.WriteLine($"Total members: {names.Count}"); ``` -------------------------------- ### Run SampleApi using .NET CLI Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Api/docs/guide/getting-started.md This command navigates to the SampleApi directory and starts the API using the .NET CLI. Ensure the .NET 9 SDK is installed. This command has no direct input or output other than starting the API service. ```bash cd samples/SampleApi dotnet run ``` -------------------------------- ### Install SampleLibrary using .NET CLI, Package Manager, or PackageReference Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/guide/getting-started.md Demonstrates how to add the SampleLibrary NuGet package to a .NET project using three common methods: the .NET CLI, the Package Manager Console in Visual Studio, and directly within a project file using PackageReference. ```bash dotnet add package SampleLibrary --version 2.0.0 ``` ```powershell Install-Package SampleLibrary -Version 2.0.0 ``` ```xml ``` -------------------------------- ### Initialize and Serve MokaDocs Project Source: https://github.com/jacobwi/moka.docs/blob/master/docs/getting-started/quickstart.md Commands to initialize a new MokaDocs project structure and start the local development server for live previewing of documentation. ```bash mokadocs init mokadocs serve mokadocs build ``` -------------------------------- ### Configure MokaDocs Site Source: https://github.com/jacobwi/moka.docs/blob/master/docs/getting-started/quickstart.md Example configuration for the mokadocs.yaml file, defining site metadata, project paths, and enabled features like search. ```yaml site: title: "My Library Docs" description: "Documentation for MyLibrary" content: docs: ./docs projects: - path: ./src/MyLibrary/MyLibrary.csproj label: "MyLibrary" theme: name: default features: search: enabled: true ``` -------------------------------- ### Quick Example of SampleLibrary Core Types in C# Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/guide/getting-started.md A complete C# console application showcasing the core functionalities of SampleLibrary, including arithmetic operations, result handling with `OperationResult`, shape abstractions, observable collections, and extension methods. ```csharp using SampleLibrary; // Arithmetic var calc = new Calculator(); Console.WriteLine(calc.Add(10, 20)); // 30 Console.WriteLine(calc.Divide(100, 3)); // 33.333... // Result handling var result = calc.TryDivide(10, 0); if (!result.Success) Console.WriteLine(result.Error); // "Cannot divide by zero." // Shapes IShape circle = new Circle(5.0); IShape rect = new Rectangle(4.0, 6.0); Console.WriteLine($"{circle.Name}: {circle.CalculateArea():F2}"); // Circle: 78.54 Console.WriteLine($"{rect.Name}: {rect.CalculateArea():F2}"); // Rectangle: 24.00 // Observable collections var list = new ObservableList(); list.ItemAdded += (_, item) => Console.WriteLine($"Added: {item}"); list.Add("Hello"); // Added: Hello // Extension methods Console.WriteLine("A very long title".Truncate(10)); // "A very..." Console.WriteLine(42.Clamp(0, 100)); // 42 ``` -------------------------------- ### POST /api/todos Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Api/docs/guide/getting-started.md Creates a new todo item in the system. ```APIDOC ## POST /api/todos ### Description Creates a new todo item with a title and priority level. ### Method POST ### Endpoint https://localhost:5001/api/todos ### Request Body - **title** (string) - Required - The title of the todo item - **priority** (string) - Required - The priority level (Low, Medium, High, Critical) ### Request Example { "title": "Buy groceries", "priority": "High" } ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the todo - **title** (string) - The title of the todo - **isCompleted** (boolean) - Completion status - **priority** (string) - Priority level - **createdAt** (string) - ISO 8601 timestamp #### Response Example { "id": 1, "title": "Buy groceries", "isCompleted": false, "priority": "High", "dueDate": null, "createdAt": "2026-03-19T10:30:00Z" } ``` -------------------------------- ### Install and Run MokaDocs CLI Source: https://github.com/jacobwi/moka.docs/blob/master/README.md These commands show how to install the MokaDocs command-line interface globally, initialize a new project, start a development server with hot reloading, and build the documentation site for production. ```bash dotnet tool install -g mokadocs mokadocs init mokadocs serve mokadocs build ``` -------------------------------- ### NuGet Installation Commands Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/api-docs.md Provides examples of NuGet package installation commands generated by MokaDocs based on extracted package metadata. These commands cover common installation methods: .NET CLI, Package Manager Console, and PackageReference. ```bash dotnet add package MyLibrary --version 2.1.0 ``` ```powershell Install-Package MyLibrary -Version 2.1.0 ``` ```xml ``` -------------------------------- ### GET /api/products Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.AspNetCore/docs/guide/getting-started.md Retrieves a list of all available products in the system. ```APIDOC ## GET /api/products ### Description Returns a list of all products currently stored in the system. ### Method GET ### Endpoint /api/products ### Response #### Success Response (200) - **products** (array) - A list of product objects. #### Response Example { "products": [ { "id": 1, "name": "Sample Product" } ] } ``` -------------------------------- ### Create and Configure Console Project (Bash) Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/blog/getting-started-tutorial.md Scaffolds a new .NET console application and adds the SampleLibrary package. This is the initial setup for the project. ```bash dotnet new console -n ShapeCalculator cd ShapeCalculator dotnet add package SampleLibrary --version 2.0.0 ``` -------------------------------- ### Bash Syntax Highlighting for Package Managers Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/markdown.md Provides examples of bash commands for installing a package using different package managers (npm, yarn, pnpm) within tabbed content. ```bash npm install my-package ``` ```bash yarn add my-package ``` ```bash pnpm add my-package ``` -------------------------------- ### POST /api/products Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.AspNetCore/docs/guide/getting-started.md Creates a new product entry in the system. ```APIDOC ## POST /api/products ### Description Creates a new product record. ### Method POST ### Endpoint /api/products ### Request Body - **name** (string) - Required - The name of the product. ### Request Example { "name": "New Product" } ### Response #### Success Response (200) - **id** (integer) - The ID of the created product. ``` -------------------------------- ### Install and Configure SampleLibrary Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/guide/features.md Instructions for adding the SampleLibrary package to a .NET project and initializing the Calculator class. ```bash dotnet add package SampleLibrary --version 2.0.0 ``` ```csharp using SampleLibrary; var calc = new Calculator(); int sum = calc.Add(3, 7); // 10 ``` -------------------------------- ### GET /api/weather/forecast Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Api/docs/guide/getting-started.md Retrieves the weather forecast for a specified number of days. ```APIDOC ## GET /api/weather/forecast ### Description Fetches the daily weather forecast based on the requested number of days. ### Method GET ### Endpoint https://localhost:5001/api/weather/forecast ### Parameters #### Query Parameters - **days** (integer) - Optional - The number of days to retrieve the forecast for ### Request Example curl https://localhost:5001/api/weather/forecast?days=3 ### Response #### Success Response (200) - **forecasts** (array) - List of WeatherForecast objects ``` -------------------------------- ### Install Moka.docs on Different Operating Systems Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/markdown.md Provides installation instructions for Moka.docs on Windows, macOS, and Linux. For macOS, it uses Homebrew. For Linux, it shows commands for Debian/Ubuntu and Fedora. ```markdown === "Windows" 1. Download the installer from the releases page 2. Run `setup.exe` 3. Follow the installation wizard === "macOS" Install via Homebrew: ```bash brew install mokadocs ``` === "Linux" Install via the package manager for your distribution: ```bash # Debian/Ubuntu sudo apt install mokadocs # Fedora sudo dnf install mokadocs ``` === ``` -------------------------------- ### Provide Code Examples with Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/api-docs.md The tag provides a code sample demonstrating how to use a type or member. It typically contains a block to format the code. ```csharp /// /// Registers MokaDocs services in the dependency injection container. /// /// /// /// var builder = WebApplication.CreateBuilder(args); /// builder.Services.AddMokaDocs(options => /// { /// options.Title = "My Documentation"; /// options.BaseUrl = "https://docs.example.com"; /// }); /// /// public static IServiceCollection AddMokaDocs( this IServiceCollection services, Action configure) { } ``` -------------------------------- ### Error Handling in SampleLibrary: Exceptions vs. OperationResult Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/guide/getting-started.md Illustrates two approaches to handling errors in SampleLibrary's `Calculator` class: traditional exception handling for invalid operations like division by zero, and the use of `OperationResult` for safer, non-exception-throwing operations. ```csharp var calc = new Calculator(); // Exception-based try { calc.Divide(10, 0); } catch (DivideByZeroException ex) { Console.WriteLine(ex.Message); // "Cannot divide by zero." } // Result-based (no exceptions) var result = calc.TryDivide(10, 0); if (!result.Success) Console.WriteLine(result.Error); // "Cannot divide by zero." ``` -------------------------------- ### MokaDocs Dev Server Output Example (Text) Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/cli-reference.md An example of the output displayed in the terminal when the MokaDocs development server starts successfully. It indicates the listening address, directories being watched, and the status of hot reload. ```text MokaDocs dev server started. Listening on: http://localhost:5080 Watching: docs/, mokadocs.yaml Hot reload: enabled (WebSocket) Press Ctrl+C to stop. ``` -------------------------------- ### Complete MokaDocs Configuration Example Source: https://github.com/jacobwi/moka.docs/blob/master/docs/configuration/site-config.md A comprehensive example showing the full structure of a mokadocs.yaml file, including site metadata, content paths, theme customization, search features, versioning, plugins, and navigation. ```yaml site: title: "Contoso SDK Documentation" description: "Official documentation for the Contoso SDK for .NET" url: "https://docs.contoso.dev" content: docs: "./docs" projects: - path: "../src/Contoso.Sdk/Contoso.Sdk.csproj" label: "Contoso SDK" build: output: "./_site" clean: true minify: true sitemap: true robots: true cache: true ``` -------------------------------- ### Run SampleApi using .NET CLI Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Api/docs/index.md Executes the .NET application. This command starts the local development server, making the API available at https://localhost:5001. ```bash dotnet run ``` -------------------------------- ### Install MokaDocs CLI Source: https://context7.com/jacobwi/moka.docs/llms.txt Commands to install MokaDocs as a global or local .NET tool. Use these to set up the environment before initializing projects. ```bash dotnet tool install -g mokadocs mokadocs --version dotnet tool update -g mokadocs dotnet new tool-manifest dotnet tool install mokadocs ``` -------------------------------- ### C# Syntax Highlighting Example Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/markdown.md Demonstrates basic C# syntax highlighting within MokaDocs. This block showcases a simple 'Hello, World!' program in C#. ```csharp public class HelloWorld { public static void Main(string[] args) { Console.WriteLine("Hello, MokaDocs!"); } } ``` -------------------------------- ### String Truncation using SampleLibrary Extension Methods in C# Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/guide/getting-started.md Demonstrates the usage of the `Truncate` extension method provided by SampleLibrary in C#. This method allows for shortening strings to a specified length and optionally appending a custom suffix. ```csharp string text = "This is a very long string that needs truncating"; string short1 = text.Truncate(20); // "This is a very lo..." string short2 = text.Truncate(20, " [...] "); // "This is a very[...]" ``` -------------------------------- ### POST /api/repl/execute Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/dev-server.md Compiles and executes C# code using Roslyn to power interactive code examples. ```APIDOC ## POST /api/repl/execute ### Description Compiles and executes C# code using Roslyn. This endpoint is available when the REPL plugin is enabled. ### Method POST ### Endpoint /api/repl/execute ### Request Body - **code** (string) - Required - The C# source code to execute. - **references** (array) - Optional - A list of assembly references (e.g., ["System.Linq"]). ### Request Example { "code": "Console.WriteLine(\"Hello, world!\");", "references": ["System.Linq"] } ### Response #### Success Response (200) - **success** (boolean) - Indicates if execution was successful. - **output** (string) - The standard output from the code execution. - **error** (string|null) - Error message if compilation or execution failed. - **executionTimeMs** (number) - Time taken for execution in milliseconds. #### Response Example { "success": true, "output": "Hello, world!\n", "error": null, "executionTimeMs": 42 } ``` -------------------------------- ### Create Step-by-Step Instructions Source: https://context7.com/jacobwi/moka.docs/llms.txt Use the steps component to render a numbered sequence of instructions. This is ideal for installation guides or multi-stage workflows. ```markdown :::steps ### Install the CLI tool Install MokaDocs globally using the .NET CLI: ```bash dotnet tool install -g mokadocs ``` ::: ``` -------------------------------- ### Generate MokaDocs Component Example (Bash) Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/cli-reference.md Commands to generate example pages for built-in MokaDocs components. This helps users quickly understand how components like 'card' or 'code-group' work and provides starter markup. ```bash # Generate a card component example page mokadocs new component card # Generate a code-group example mokadocs new component code-group ``` -------------------------------- ### XML Documentation: Parameter Documentation Example (C#) Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/api-docs.md Shows an example of thorough XML documentation for a method parameter in C#. The `maxDepth` parameter's documentation explains its valid range, purpose, and default value. ```csharp /// /// The maximum depth to traverse when building the navigation tree. /// Must be between 1 and 10 inclusive. A value of 1 shows only /// top-level pages. Defaults to 3. /// public NavigationTree Build(int maxDepth = 3) { } ``` -------------------------------- ### Create a Todo item using cURL Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Api/docs/guide/getting-started.md This cURL command demonstrates how to create a new todo item by sending a POST request to the API's /api/todos endpoint. It includes a JSON payload specifying the todo's title and priority. The expected output is a JSON object representing the newly created todo item. ```bash curl -X POST https://localhost:5001/api/todos \ -H "Content-Type: application/json" \ -d '{"title": "Buy groceries", "priority": "High"}' ``` -------------------------------- ### Versioned Site Configuration (YAML) Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/versioning.md An example YAML configuration for enabling and defining documentation versions in Moka Docs. This setup specifies the site title, description, versioning strategy, and details for multiple documentation versions including their labels, branches, and default/prerelease status. ```yaml site: title: MyLibrary Docs description: Documentation for MyLibrary features: versioning: enabled: true strategy: directory versions: - label: "v3.0-beta" branch: dev prerelease: true - label: "v2.0" branch: main default: true - label: "v1.0" branch: release/1.0 build: output: _site ``` -------------------------------- ### Start MokaDocs Dev Server (Bash) Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/cli-reference.md Commands to start the MokaDocs development server with various options. This includes starting on the default or a custom port, disabling the auto-open browser feature, specifying a configuration file, and enabling verbose logging for debugging. ```bash # Start the dev server on the default port (5080) mokadocs serve # Start on a custom port mokadocs serve --port 3000 # Start without opening the browser mokadocs serve --no-open # Start with a specific config file mokadocs serve --config mokadocs.prod.yaml # Start with verbose logging to debug issues mokadocs serve --verbose ``` -------------------------------- ### Serve Documentation Locally Source: https://context7.com/jacobwi/moka.docs/llms.txt Starts a local development server with hot-reload capabilities for previewing documentation changes in real-time. ```bash mokadocs serve mokadocs serve --port 3000 mokadocs serve --no-open ``` -------------------------------- ### MokaDocs Configuration Example Source: https://github.com/jacobwi/moka.docs/blob/master/README.nuget.md A sample MokaDocs configuration file in YAML format. It defines site metadata, content sources (docs and projects), theme options, and enabled plugins. ```yaml site: title: "My Library" description: "Documentation for My Library" content: docs: ./docs projects: - path: ./src/MyLibrary/MyLibrary.csproj theme: options: primaryColor: "#0ea5e9" codeTheme: catppuccin-mocha codeStyle: macos plugins: - name: mokadocs-repl - name: mokadocs-changelog ``` -------------------------------- ### Start MokaDocs Development Server Source: https://context7.com/jacobwi/moka.docs/llms.txt Starts the MokaDocs development server with verbose logging enabled. This command is useful for debugging and monitoring the server's activity during development. It listens on a local port and watches for changes in specified directories. ```bash mokadocs serve --verbose ``` -------------------------------- ### Gantt Chart Example in Mermaid Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/diagrams.md Demonstrates how to create a Gantt chart for project timelines and scheduling using Mermaid syntax. This is useful for visualizing project phases and task durations. ```mermaid gantt title MokaDocs v2.0 Release Plan dateFormat YYYY-MM-DD section Core Markdown engine upgrade :done, core1, 2025-01-01, 30d API doc generator :done, core2, after core1, 20d Search index builder :active, core3, after core2, 15d section UI Theme redesign :ui1, after core1, 25d Component library :ui2, after ui1, 20d Mobile responsive :ui3, after ui2, 10d section Release Beta testing :rel1, after core3, 14d Documentation :rel2, after ui3, 10d Public release :milestone, rel3, after rel2, 0d ``` -------------------------------- ### Example REPL Code with Console Output Source: https://github.com/jacobwi/moka.docs/blob/master/docs/plugins/repl.md This C# REPL code snippet demonstrates basic console output using `Console.WriteLine` and `Console.Write`, including formatted and interpolated strings. It showcases how standard console operations are captured and displayed. ```csharp ```csharp-repl Console.WriteLine("Hello, World!"); Console.Write("No "); Console.Write("newline "); Console.WriteLine("here."); Console.WriteLine($"2 + 2 = {2 + 2}"); ``` ``` -------------------------------- ### Dockerfile for Serving MokaDocs Static Content with Nginx Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/deployment.md A Dockerfile example for serving MokaDocs generated static content using Nginx. This allows for containerized deployment of the static site. ```dockerfile # Dockerfile ``` -------------------------------- ### Implement Plugin ID and Initialize Options Source: https://github.com/jacobwi/moka.docs/blob/master/docs/plugins/overview.md Demonstrates how to define a plugin's unique ID and retrieve configuration options during the initialization phase. The InitializeAsync method allows for validation and setup using the IPluginContext. ```csharp // In your plugin class public string Id => "mokadocs-repl"; public Task InitializeAsync(IPluginContext context, CancellationToken ct) { if (context.Options.TryGetValue("outputPath", out var value)) { _outputPath = value?.ToString() ?? "./default"; } return Task.CompletedTask; } ``` -------------------------------- ### MokaDocs Configuration Example Source: https://github.com/jacobwi/moka.docs/blob/master/README.md This YAML configuration file shows various settings for MokaDocs, including site title and description, content paths for documentation and projects, theme options like primary color and code theme, and plugin configurations. ```yaml # mokadocs.yaml site: title: "My Library" description: "Documentation for My Library" content: docs: ./docs projects: - path: ./src/MyLibrary/MyLibrary.csproj theme: name: default options: primaryColor: "#0ea5e9" codeTheme: catppuccin-mocha codeStyle: macos plugins: - name: mokadocs-repl - name: mokadocs-changelog ``` -------------------------------- ### C# Code within a Tip Admonition Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/markdown.md Demonstrates embedding C# code within a 'tip' type admonition in MokaDocs. This example shows how to register MokaDocs services in a DI container. ```markdown ::: tip Using Dependency Injection You can register MokaDocs services in your DI container: 1. Add the NuGet package 2. Call the registration method: ```csharp services.AddMokaDocs(options => { options.Title = "My Docs"; }); ``` See the [configuration guide](./configuration.md) for more details. ::: ``` -------------------------------- ### Configure MokaDocs REPL Plugin Source: https://github.com/jacobwi/moka.docs/blob/master/docs/plugins/repl.md Configures the REPL plugin in the mokadocs.yaml file. Supports basic installation and the inclusion of external NuGet packages with optional versioning. ```yaml plugins: - name: mokadocs-repl ``` ```yaml plugins: - name: mokadocs-repl options: packages: - Newtonsoft.Json - Humanizer@2.14.1 ``` ```yaml plugins: - name: mokadocs-repl options: packages: - Newtonsoft.Json - Humanizer@2.14.1 - FluentValidation@11.0.0 ``` -------------------------------- ### Serve MokaDocs Locally Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/cli-reference.md Starts a local development server with hot-reload capabilities to preview documentation changes in real-time. Allows configuration of the port and browser behavior. ```bash mokadocs serve ``` -------------------------------- ### Start MokaDocs Development Server Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/dev-server.md Commands to initiate the local development server with various configuration options such as custom ports, verbose logging, and alternative configuration files. ```bash mokadocs serve mokadocs serve --port 3000 mokadocs serve --verbose mokadocs serve --config mokadocs.dev.yaml ``` -------------------------------- ### XML Documentation: Good Summary Example (C#) Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/api-docs.md Contrasts a 'bad' XML documentation summary that states the obvious with a 'good' summary that explains the purpose of the `Name` property in C#. ```csharp // Bad: States the obvious /// /// The name property. /// public string Name { get; set; } // Good: Explains the purpose /// /// Gets or sets the display name shown in the site navigation sidebar. /// public string Name { get; set; } ``` -------------------------------- ### Display Steps with Code Groups (Markdown) Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/components.md This snippet shows how to use the `steps` component to create a multi-step guide. Each step can contain other components, including `code-group` to display code snippets for different package managers like npm and yarn. ```markdown :::steps ### Choose your package manager :::code-group ```bash title="npm" npm install mokadocs ``` ```bash title="yarn" yarn add mokadocs ``` ::: ### Configure your project :::card{title="Configuration File" icon="settings"} Create a `mokadocs.yml` file in your project root. See the [configuration reference](/configuration/site-config) for all available options. ::: ::: ``` -------------------------------- ### Scaffold New MokaDocs Pages, Plugins, and Components Source: https://context7.com/jacobwi/moka.docs/llms.txt Commands to generate new documentation pages, plugins, or component examples. These commands help in quickly setting up new content structures with options for custom titles, ordering, paths, and layouts. ```bash # Create a new documentation page mokadocs new page getting-started # Create page with custom title and order mokadocs new page installation --title "Installation Guide" --order 1 # Create page in subdirectory with specific layout mokadocs new page overview --path ./docs/guides --layout wide # Scaffold a new plugin project mokadocs new plugin MyCustomPlugin # Generate component example page mokadocs new component card mokadocs new component steps mokadocs new component link-cards mokadocs new component code-group mokadocs new component changelog ``` -------------------------------- ### GET /api/products/{id} Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.AspNetCore/docs/guide/getting-started.md Retrieves details for a specific product by its unique identifier. ```APIDOC ## GET /api/products/{id} ### Description Fetches the details of a specific product using its ID. ### Method GET ### Endpoint /api/products/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the product. ### Response #### Success Response (200) - **id** (integer) - Product ID - **name** (string) - Product name #### Response Example { "id": 1, "name": "Sample Product" } ``` -------------------------------- ### Migrate OperationResult Initialization Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/blog/release-v2.md Shows the migration from manual object initialization to using the new factory methods. ```csharp // Old var r = new OperationResult { Success = true, Value = 42 }; // New var r = OperationResult.Ok(42); ``` -------------------------------- ### Perform basic arithmetic with Calculator Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/index.md Demonstrates how to instantiate the Calculator class and perform a basic addition operation. This returns an integer result based on the provided inputs. ```csharp var calc = new Calculator(); var result = calc.Add(2, 3); // returns 5 ``` -------------------------------- ### Configure MokaDocs in ASP.NET Core Program.cs Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.AspNetCore/docs/guide/getting-started.md This C# code snippet demonstrates how to add MokaDocs services to your ASP.NET Core application's service collection and map the MokaDocs endpoints. It configures MokaDocs to use specified assemblies for API discovery and a local directory for Markdown guides. The documentation will be served at the default '/docs' path. ```csharp builder.Services.AddMokaDocs(options => { options.Title = "Product API"; options.Assemblies = [typeof(Product).Assembly]; options.DocsPath = "./docs"; }); app.MapMokaDocs(); ``` -------------------------------- ### DELETE /api/products/{id} Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.AspNetCore/docs/guide/getting-started.md Removes a product from the system. ```APIDOC ## DELETE /api/products/{id} ### Description Deletes a product record by ID. ### Method DELETE ### Endpoint /api/products/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the product to delete. ### Response #### Success Response (200) - **status** (string) - Confirmation of deletion. ``` -------------------------------- ### PUT /api/products/{id} Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.AspNetCore/docs/guide/getting-started.md Updates an existing product's information. ```APIDOC ## PUT /api/products/{id} ### Description Updates the details of an existing product. ### Method PUT ### Endpoint /api/products/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the product to update. ### Request Body - **name** (string) - Optional - The new name for the product. ### Response #### Success Response (200) - **status** (string) - Success message. ``` -------------------------------- ### Create OperationResult with Factory Methods Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/blog/release-v2.md Shows how to use the new static Ok and Fail factory methods to instantiate OperationResult objects. ```csharp var success = OperationResult.Ok(42); var failure = OperationResult.Fail("Something went wrong"); ``` -------------------------------- ### Build and Deploy MokaDocs Site Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/components.md Command-line instruction to generate the static documentation site. The output is directed to a specified folder, which is then ready for deployment to a hosting provider. ```bash mokadocs build --output ./dist ``` -------------------------------- ### Check Weather Forecast using cURL Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Api/docs/guide/getting-started.md This cURL command fetches the weather forecast for a specified number of days from the API. It sends a GET request to the /api/weather/forecast endpoint with a 'days' query parameter. The response is a JSON object containing weather details. ```bash curl https://localhost:5001/api/weather/forecast?days=3 ``` -------------------------------- ### Build and Serve Documentation (Bash) Source: https://github.com/jacobwi/moka.docs/blob/master/docs/plugins/overview.md Commands to build the MokaDocs site or start the development server. These commands trigger the MokaDocs build process, which will load and execute registered plugins, including the custom footer plugin. The output is the generated static website or a live development server. ```bash mokadocs build # or mokadocs serve ``` -------------------------------- ### Moka.docs Development and Production Commands Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/markdown.md Demonstrates Moka.docs commands for development and production environments using tabs and admonitions. Includes commands for running a dev server with hot reload and building for production. ```markdown === "Development" ::: tip Run the dev server with hot reload: ```bash mokadocs serve --watch ``` ::: === "Production" ::: warning Always build before deploying: ```bash mokadocs build --output ./dist ``` ::: === ``` -------------------------------- ### Initialize Rectangle Shape Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/blog/release-v2.md Demonstrates how to instantiate the new Rectangle class and utilize its properties and area calculation method. ```csharp var rect = new Rectangle(4.0, 6.0); Console.WriteLine(rect.Name); // "Rectangle" Console.WriteLine(rect.CalculateArea()); // 24.0 ``` -------------------------------- ### Initialize MokaDocs Project Source: https://context7.com/jacobwi/moka.docs/llms.txt Scaffolds a new documentation project directory with the necessary configuration files and starter content. ```bash mkdir my-library-docs cd my-library-docs mokadocs init ``` -------------------------------- ### Show Multi-Language Code Examples Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/guide/components.md The Code Group component allows grouping multiple code blocks into a tabbed interface, ideal for showcasing examples in different programming languages. ```markdown :::code-group ```csharp title="C#" var calculator = new Calculator(); var result = calculator.Add(2, 3); Console.WriteLine(result); // 5 ``` ```fsharp title="F#" let calculator = Calculator () let result = calculator.Add(2, 3) printfn "%d" result // 5 ``` ```python title="Python" # Using the Python bindings calculator = Calculator() result = calculator.add(2, 3) print(result) # 5 ``` ::: ``` -------------------------------- ### Initialize MokaDocs Project Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/cli-reference.md Scaffolds a new documentation project by creating a configuration file and a source directory. This command should be run in the directory where you want to host your documentation. ```bash mokadocs init ``` ```bash mkdir my-library-docs cd my-library-docs mokadocs init ``` -------------------------------- ### Configure Icons in Front Matter and Navigation Source: https://github.com/jacobwi/moka.docs/blob/master/docs/configuration/navigation.md Demonstrates how to assign Lucide icons to pages via front matter and to navigation items in the configuration file. Icons in navigation take precedence over front matter definitions. ```yaml --- title: "Security Guide" icon: "shield" --- ``` ```yaml nav: - label: "Deployment" icon: "globe" children: - label: "Azure" path: "/deployment/azure" icon: "cloud" - label: "Docker" path: "/deployment/docker" icon: "container" ``` -------------------------------- ### Use Numeric Extensions Source: https://github.com/jacobwi/moka.docs/blob/master/samples/Moka.Docs.Samples.Library/docs/blog/release-v2.md Demonstrates the usage of Clamp and IsInRange extension methods on integer types. ```csharp int clamped = 150.Clamp(0, 100); // 100 bool valid = 42.IsInRange(0, 100); // true ``` -------------------------------- ### Build MokaDocs for Production Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/deployment.md Commands to build the MokaDocs static site for production. Includes options for a clean build without caching. ```bash mokadocs build mokadocs clean && mokadocs build --no-cache ``` -------------------------------- ### Install MokaDocs NuGet Package Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/aspnetcore.md Command to add the Moka.Docs.AspNetCore package to an existing ASP.NET Core project. ```bash dotnet add package Moka.Docs.AspNetCore ``` -------------------------------- ### Customize MokaDocs Options Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/aspnetcore.md Example of configuring MokaDocs appearance and behavior using the MokaDocsOptions class during service registration. ```csharp builder.Services.AddMokaDocs(options => { options.Title = "Contoso API"; options.Description = "Developer documentation for the Contoso platform"; options.Version = "v2.1"; options.PrimaryColor = "#6d28d9"; options.AccentColor = "#f59e0b"; options.BasePath = "/docs"; options.Copyright = "© 2026 Contoso Ltd."; options.DocsPath = "Docs"; options.CacheOutput = true; }); ``` -------------------------------- ### Configure MokaDocs in ASP.NET Core Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/aspnetcore.md Basic setup for registering MokaDocs services and mapping documentation endpoints in the application pipeline. ```csharp using Moka.Docs.AspNetCore; var builder = WebApplication.CreateBuilder(args); // Register MokaDocs services builder.Services.AddMokaDocs(); var app = builder.Build(); // Map the documentation endpoints app.MapMokaDocs(); app.Run(); ``` -------------------------------- ### XML Documentation Tags Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/api-docs.md Overview of supported XML documentation tags including type parameters, return values, exceptions, examples, and cross-references. ```APIDOC ## XML Documentation Tags ### Description MokaDocs supports standard C# XML documentation tags to generate API pages. These tags provide metadata about generic types, method returns, exceptions, and usage examples. ### Supported Tags - ****: Describes generic type parameters. - ****: Describes the return value of a method. - ****: Documents exceptions thrown by a method. - ****: Provides code snippets showing API usage. - ****: Creates cross-references to related types or external documentation. ### Example Usage ```csharp /// /// Reads and parses a configuration file. /// /// Path to the configuration file. /// Thrown if file is missing. public Config LoadConfig(string path) { } ``` ``` -------------------------------- ### Pie Chart Example in Mermaid Source: https://github.com/jacobwi/moka.docs/blob/master/docs/guide/diagrams.md Illustrates how to create a pie chart to display proportional data using Mermaid syntax. This is effective for showing the distribution of categories. ```mermaid pie title Documentation Pages by Category "Guides" : 42 "API Reference" : 35 "Tutorials" : 15 "FAQ" : 8 ``` -------------------------------- ### Automate CI/CD with GitHub Actions Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/deployment.md GitHub Actions workflows for caching .NET tools to speed up builds and validating documentation on pull requests to ensure build integrity. ```yaml - name: Cache .NET tools uses: actions/cache@v4 with: path: ~/.dotnet/tools key: dotnet-tools-${{ runner.os }}-mokadocs - name: Install MokaDocs run: dotnet tool install --global MokaDocs.Cli || true ``` ```yaml name: Validate Documentation on: pull_request: paths: - 'docs/**' - 'mokadocs.yaml' jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' - name: Install MokaDocs run: dotnet tool install --global MokaDocs.Cli - name: Build documentation run: mokadocs build --verbose - name: Check for build warnings run: | if mokadocs build 2>&1 | grep -q "WARNING"; then echo "::warning::Documentation build produced warnings" fi ``` -------------------------------- ### Page-Level Version Constraint Source: https://github.com/jacobwi/moka.docs/blob/master/docs/advanced/versioning.md Example of applying a page-level version constraint using front matter. This allows individual pages to be included only in specific versions or version ranges. ```yaml --- title: New Feature Guide version: ">=2.0" --- ```