Skip to content

Commit

Permalink
Merge pull request #1 from danielsitnik/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
danielsitnik authored Aug 5, 2021
2 parents f93775f + 1455cff commit 98088db
Show file tree
Hide file tree
Showing 12 changed files with 5,446 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will run tests using node and then publish a package to NPM when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12.x
- run: npm ci
# - run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12.x
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_auth_token}}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ dist

# TernJS port file
.tern-port

# Webstorm
.idea
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,80 @@
# codedoc-mermaid-plugin
Mermaid plugin for Codedoc
This plugin enables the use of [Mermaid](https://mermaid-js.github.io) diagrams in [Codedoc](https://codedoc.cc) documents.

## Installation
Using the Codedoc CLI, run the following command inside your project's folder:
```bash
$ 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.

```ts
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](https://mermaid-js.github.io/mermaid/#/Setup) 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:
```ts
// 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:
```md
> :Mermaid
> > graph LR
> > Start --> End
```

Another way to do it is with just one `>` sign, but you **must** add a blank line below `:Mermaid`:
```md
> :Mermaid
>
> graph LR
> Start --> End
```
Refer to the "Diagram Syntax" section of Mermaid's [documentation](https://mermaid-js.github.io) 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](https://choosealicense.com/licenses/mit/)
25 changes: 25 additions & 0 deletions conf/typescript/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"alwaysStrict": true,
"declaration": true,
"sourceMap": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"jsx": "react",
"jsxFactory": "renderer.create",
"lib": [
"es2017",
"dom"
]
},
"include": [
"../../src/**/*"
]
}
7 changes: 7 additions & 0 deletions conf/typescript/es5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./base",
"compilerOptions": {
"target": "es5",
"outDir": "../../dist/es5/"
}
}
8 changes: 8 additions & 0 deletions conf/typescript/es6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./base",
"compilerOptions": {
"inlineSources": true,
"target": "es6",
"outDir": "../../dist/es6/"
}
}
Loading

0 comments on commit 98088db

Please sign in to comment.