Giter Site home page Giter Site logo

codedoc-mermaid-plugin's Introduction

codedoc-mermaid-plugin

This plugin enables the use of Mermaid diagrams in Codedoc documents.

Installation

Using the Codedoc CLI, run the following command inside your project's folder:

$ codedoc install codedoc-mermaid-plugin

Configuration

To use the plugin, first edit your config.ts file like below. Make sure you import the plugin at the top of the file, and then add it to the plugins section in the configuration function.

import { configuration } from '@codedoc/core';
import { mermaidPlugin } from 'codedoc-mermaid-plugin' // --> import the plugin
import { theme } from './theme';

export const config = /*#__PURE__*/configuration({
    theme,
    page: {
        title: {
            base: 'Mermaid Plugin'
        }
    },
    plugins: [
        mermaidPlugin()   // --> make sure you add this section
    ]
});

Customizing Configuration

Mermaid's configuration can be changed by passing a MermaidOptions object to the mermaidPlugin() function. Basically all the options described here are supported.

For example, if you wanted to change the theme to neutral and to change the spacing between flowchart nodes, you would do this:

// imports removed for brevity
export const config = /*#__PURE__*/configuration({
    theme,
    page: {
        title: {
            base: 'Mermaid Plugin'
        }
    },
    plugins: [
        mermaidPlugin({
            theme: "neutral",
            flowchart: {
                nodeSpacing: 75
            }
        })
    ]
});

Usage

To render diagrams in your documents, all you need to do is wrap Mermaid's diagram syntax in markdown block-quote elements (Codedoc calls them "quoted components") like below:

> :Mermaid
> > graph LR
> >   Start --> End

Another way to do it is with just one > sign, but you must add a blank line below :Mermaid:

> :Mermaid
>
> graph LR
>   Start --> End

Refer to the "Diagram Syntax" section of Mermaid's documentation to learn how to use each of the diagrams.

Contributing

If you'd like to contribute to this plugin, here are some ideas for improvements:

  1. Add some styling so the diagrams can be rendered inside some container, similar to the code blocks.
  2. Find a way to dynamically change the theme when switching between light/dark mode. Right now the neutral theme is the one that works best with both modes.

License

MIT

codedoc-mermaid-plugin's People

Contributors

danielsitnik avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.