Skip to content

Commit

Permalink
feat(plugin): Setup optional the admonish mdbook plugin
Browse files Browse the repository at this point in the history
Close #300
  • Loading branch information
jontze committed Dec 7, 2022
1 parent c1f1cc4 commit da36206
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
use-mermaid: true
use-toc: true
use-opengh: true
use-admonish: true
- name: Test mdBook binary
run: mdbook --version
- name: Test mdbook-linkcheck binary
Expand All @@ -63,6 +64,8 @@ jobs:
run: mdbook-toc --version
- name: Test mdbook-open-on-gh binary
run: mdbook-open-on-gh --version
- name: Test mdbook-admonish binary
run: mdbook-admonish --version

release:
needs: [integration_test]
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,26 @@ jobs:
use-opengh: true
- name: Test mdbook-open-on-gh binary
run: mdbook-open-on-gh --version || exit 1

admonish:
needs: [mdBook]
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
version: [14, 16, 18]
runs-on: ${{ matrix.os }}
name: Mdbook Admonish (Node ${{ matrix.version }} - ${{ matrix.os }})
steps:
- uses: actions/checkout@v3
- name: Setup matrix node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
- name: Download latest admonish
uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
use-admonish: true
- name: Test mdbook-admonish binary
run: mdbook-admonish --version || exit 1
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This action runs only on linux and is well tested on github **latest ubuntu** ru
- [badboy/mdbook-mermaid](https://github.com/badboy/mdbook-mermaid)
- [badboy/mdbook-toc](https://github.com/badboy/mdbook-toc)
- [badboy/mdbook-open-on-gh](https://github.com/badboy/mdbook-open-on-gh)
- [tommilligan/mdbook-admonish](https://github.com/tommilligan/mdbook-admonish)

## Fast Setup

Expand All @@ -39,6 +40,7 @@ jobs:
use-mermaid: true
use-toc: true
use-opengh: true
use-admonish: true
- name: Show mdbook version
run: mdbook --version
- name: Show linkchecker version
Expand All @@ -49,6 +51,8 @@ jobs:
run: mdbook-toc --version
- name: Show open-on-gh version
run: mdbook-open-on-gh --version
- name: Show admonish version
run: mdbook-admonish --version
```
## Advanced Setup
Expand Down Expand Up @@ -77,6 +81,8 @@ jobs:
toc-version: "~0.7.0"
use-opengh: true
opengh-version: "~2.0.0"
use-admonish: true
admonish-version: "~1.8.0"
- name: Show mdbook version
run: mdbook --version
- name: Show linkchecker version
Expand All @@ -87,6 +93,8 @@ jobs:
run: mdbook-toc --version
- name: Show open-on-gh version
run: mdbook-open-on-gh --version
- name: Show admonish version
run: mdbook-admonish --version
```
## Contributions
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ inputs:
description: open-on-gh version that should be used
required: false
default: "latest"
use-admonish:
description: "Use admonish plugin (true / false)"
required: false
default: false
admonish-version:
description: admonish version that should be used
required: false
default: "latest"
runs:
using: "node16"
main: "./dist/index.js"
Expand Down
7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as core from "@actions/core";
import { MdBook } from "./mdbook/MdBook";
import { Admonish } from "./mdbook/plugins/Admonish";
import { Linkcheck } from "./mdbook/plugins/Linkcheck";
import { Mermaid } from "./mdbook/plugins/Mermaid";
import { OpenGh } from "./mdbook/plugins/OpenGh";
Expand Down Expand Up @@ -35,6 +36,12 @@ const run = async () => {
const openGhPlugin = new OpenGh();
await openGhPlugin.setup();
}

// Admonish - 3rd party preprocessor plugin for mdbook to add material design
if (core.getBooleanInput("use-Admonish") === true) {
const admonishPlugin = new Admonish();
await admonishPlugin.setup();
}
};

(async (): Promise<void> => {
Expand Down
20 changes: 20 additions & 0 deletions src/mdbook/plugins/Admonish.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Admonish } from "./Admonish";

import * as PluginModule from "./MdPlugin";

jest.mock("./MdPlugin");

describe("Admonish", () => {
it("should init class", () => {
const constructorSpy = jest.spyOn(PluginModule, "MdPlugin");
const admonish = new Admonish();

expect(constructorSpy).toHaveBeenCalledWith(
"tommilligan/mdbook-admonish",
"admonish-version",
"mdbook-admonish",
"unknown-linux-gnu"
);
expect(admonish).toBeDefined();
});
});
12 changes: 12 additions & 0 deletions src/mdbook/plugins/Admonish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { MdPlugin } from "./MdPlugin";

export class Admonish extends MdPlugin {
constructor() {
super(
"tommilligan/mdbook-admonish",
"admonish-version",
"mdbook-admonish",
"unknown-linux-gnu"
);
}
}

0 comments on commit da36206

Please sign in to comment.