Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"plugins": ["jest"],
"env": {
"browser" : true,
"commonjs" : true,
"es6" : true,
"node" : true,
"jest" : true
},
"extends": "eslint:recommended",
"overrides": [],
"ignorePatterns": [
"dist"
],
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"rules": {
"indent": ["error", 4, { "MemberExpression": 2 }],
"max-len": [
"error", { "code": 148 }
],
"linebreak-style": [
"error",
"unix"
],
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }],
"quotes": [
"error",
"single"
],
"key-spacing": ["error", {
"singleLine": {
"beforeColon": false,
"afterColon": true
},
"multiLine": {
"beforeColon": false,
"afterColon": true

},
"align": {
"beforeColon": true,
"afterColon": true,
"on": "colon"
}
}],
"semi": [
"error",
"always"
],
"no-unused-vars": [
"error",
{ "vars": "all", "args": "after-used", "varsIgnorePattern": "_", "argsIgnorePattern": "_"}
]
}
}
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Test and coverage
run: npm test
- name: Build
run: npm run build
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
42 changes: 42 additions & 0 deletions .github/workflows/deploy-static-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: './example'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
25 changes: 25 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: npm-publish
on:
push:
branches:
- main # Change this to your default branch
jobs:
npm-publish:
name: npm-publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Publish if version has been updated
uses: pascalgn/npm-publish-action@1.3.9
with: # All of theses inputs are optional
tag_name: "v%s"
tag_message: "v%s"
create_tag: "true"
commit_pattern: "^Release (\\S+)"
workspace: "."
publish_command: "yarn"
publish_args: "--non-interactive"
env: # More info about the environment variables in the README
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/node_modules
/dist
/dist
/coverage
.idea
**/.npmrc
58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0] -> [1.0.1]

### Added

- NPM publish workflow using [npm-publish-action](https://github.com/marketplace/actions/publish-to-npm)
- README usage description expanded with configuration example

### Fixed

- word concatenations are no longer replaced (bug with 'full stop'-regex)
- alternate glossary location is taken into account by generated links

### Removed

- Removed the TODO list from the main readme file

## [0.0.1] -> [1.0.0]
created by [Stijn Dejongh](https://github.com/stijn-dejongh).

### Added

- Jest runner and basic tests
- ESLint and configuration
- make the plugin configurable
- Section with improvements added to README file
- SonarQube definition
- Basic github workflow definition
- make terminology heading depth configurable, see [feature request #1](https://github.com/TheGreenToaster/docsify-glossary/issues/1)

### Fixed

- Replaced deprecated packages with security vulnerabilities
- Issue with multiple terminology replacements
- fix issue with terminology replacements in page headers/titles, see: [bug report #6](https://github.com/TheGreenToaster/docsify-glossary/issues/6)
- fix issue with terminology replacements in code blocks, see: [bug report #4](https://github.com/TheGreenToaster/docsify-glossary/issues/4)
- fix issue with multiple word terms, see: [bug report #13]([bug report #13](https://github.com/TheGreenToaster/docsify-glossary/issues/13))

### Changed

- Updated directory structure to fit common code conventions
- Add unit tests
- Run configurations altered
- Bumped node version to version 18

### Removed

- Webpack module builder

## [0.0.1]
created by [TheGreenToaster](https://github.com/TheGreenToaster/docsify-glossary).

86 changes: 70 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,74 @@
# docsify-glossary
Simple Glossary for Docsify that replaces occurrences of the terms with links to the glossary.
# docsify-glossary: SD Development Fork

## Install
1. Insert script into docsify document
```html
<script src="//unpkg.com/docsify-glossary/dist/docsify-glossary.min.js"></script>
```
1. Create a `_glossary.md` file in the root directory
1. Populate the `_glossary.md` file with terms.
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=stijn-dejongh_docsify-glossary&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=stijn-dejongh_docsify-glossary)

Simple Glossary for Docsify that replaces occurrences of words in text with links to the glossary definitions.
Forked from [TheGreenToaster/docsify-glossary](https://github.com/TheGreenToaster/docsify-glossary) as the original
project was unmaintained for over 3 years, to address a couple of usability issues with the original script.

An example usage can be found here [./example](./example), it is deployed automatically to this [GitHub page](https://stijn-dejongh.github.io/docsify-glossary/#/).

![Example of the glossary replacements](./example_output.png)

## Installation

1. Download the latest version of the javascript (from our [releases page](https://github.com/stijn-dejongh/docsify-glossary/releases))
2. Add the script into your docsify source directory
3. Insert script into `docsify.template.js` document
```html
<script src="./docsify-glossary.min.js"></script>
```
4. Create a `_glossary.md` file in the root directory
5. Populate the `_glossary.md` file with terms.

## Usage
* Terms must be predicated with `##### ` to get recognized by the glossary
* Terms in the documentation must be surrounded by space to get replaced by the regular expression
## Plugin Usage

* Terms must be predicated with a consistent Markdown heading to get recognized by the glossary (see configuration)
* Terms are replaced with links in the order that they appear in the glossary file.
* This is especially relevant for nested terminology ( e.g. _API_ and _API Usage_)

### Configuration

This version of the `docsify-glossary` plugin allows you to configure multiple aspects of the glossary.
An example configuration is shown here:
```yaml
glossify: {
debug: false, # default
glossaryLocation: './X_Appendix/Glossary/HOME.md', # default is '_glossary.md'
terminologyHeading: '##', # default is '####', overwrite to fit your glossary heading depth
replaceTitleTerms: false # default is 'true'
}
```

## Running the code

In order to run the code, you will need a node set-up on your local machine.
We recommend using [Node Version Manager](https://npm.github.io/installation-setup-docs/installing/using-a-node-version-manager.html) to make this easier.

### Building the code

1. Globally install [docsify](https://docsify.js.org/#/quickstart): `npm i docsify-cli -g`
2. From the project root directory, run: `npm install`
3. To build the code, run: `npm run ci`
4. THis will compile, test, and package the plugin

### View the example website

Once the code has been built, you can launch the example website illustrating the use of the glossary.
In order to do so:

1. Go to [http://localhost:3000/]()
2. copy the latest version of the code into the example website: `cp ./dist/@stijn-dejongh/docsify-glossary* ./example`
3. Run `docsify serve example`

## Changelog

An overview of all the changes made to this codebase can be found in the [CHANGELOG](./CHANGELOG.md) file included in this repository.

## TODO list

* [x] Bump dependency versions
* [x] add unit tests to the code to make this package more maintainable



## Example
1. Run `npm run-script build`
1. Run `docsify serve example`
1. Go to [http://localhost:3000/]()
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
18 changes: 16 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Yar Pirate Ipsum
# Yar Pirate Ipsum : Yellow Jack

Mizzen galleon aye Pirate Round capstan grapple jolly boat American Main tackle strike colors. Reef fathom bilge rat measured fer yer chains warp boatswain log Corsair gangway man-of-war. Cog driver schooner hands spanker lanyard furl lugger transom holystone.

Yellow Jack case shot Nelsons folly ye interloper gangway Sink me heave to capstan lanyard. Starboard bucko long boat chase spike gunwalls piracy log aft brigantine. Skysail piracy fathom sheet gangway transom boom Spanish Main tackle pressgang.

Crack Jennys tea cup Buccaneer broadside Cat o'nine tails weigh anchor bilge water scurvy jolly boat crimp haul wind. Grog take a caulk brigantine spanker haul wind knave Yellow Jack bounty poop deck red ensign. Hogshead scourge of the seven seas interloper Admiral of the Black draught pillage black spot trysail hang the jib marooned.
Crack Jennys tea cup Buccaneer broadside Cat o'nine tails weigh anchor bilge water scurvy jolly boat crimp haul wind. Grog take a caulk brigantine spanker haul wind knave Yellow Jack bounty poop deck red ensign. Hogshead scourge of the seven seas interloper Admiral of the Black draught pillage black spot trysail hang the jib marooned.

Here is some code to help the English pirate hunters find the notorious pirate Jack Rackham:
```java
public void findJackRakham() {
for(Pirate pirate : islandPopulation.getPirates()) {
// The infamous pirate admiral Jack Rackham? Oh look, there he is!
return pirate.hasFirstName("Jack") && pirate.hasLastName("Rackham");
}
}
```


Yellow Jack was an Admiral, Admiral, Admiral. (This Admiral line was added to demonstrate multiple replacements, as mentioned in [issue nr 13](https://github.com/TheGreenToaster/docsify-glossary/issues/13))
29 changes: 25 additions & 4 deletions example/_glossary.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
##### Admiral
a commander of a fleet or naval squadron, or a naval officer of very high rank.
# Glossary

##### Yellow Jack
another term for yellow flag
## A

### Admiral

A commander of a fleet or naval squadron, or a naval officer of very high rank.

## B - I

Nothing here....

## J

### Jack Rackham

Jack Rackham was a gentleman pirate with flamboyant fashion sense and a way with female pirates who were dressed like men– notably, Anne Bonny and Mary Read.


## K - X

## Y

### Yellow Jack

Another term for yellow flag
Loading