1.0.81 • Published 8 months ago

express-documentation v1.0.81

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

screenshot

How To Use

To install this package, you'll need Node.js (which comes with npm) installed on your computer. From your command line:

# Using npm
$ npm install express ejs express-documentation

# Using yarn
$ yarn add express ejs express-documentation

Documentation

Express Docs should be used as middleware in Express.js at the path where you want your docs to be located at. This translates to using the app.use method of your Express.js app and setting the location path as the first argument and the executed expressDocs method as the second property with the app variable as a parameter.

app.use("/docs", expressDocs(app));

This will use the default parameters for Express Docs:

ParameterDefault ValueAccepted Object Types
📲 TitleproductName; name; "Documentation"string
🎨 Favicon"./favicon.ico"path; URL
⏱️ Logo"./logo.png"path; URL
👨‍💻 Directory"./docs"path

All of these values should be modified like this:

app.use("/docs", expressDocs(app, {
  title: "Express Docs Demo",
  favicon: "./assets/favicon.ico",
  logo: "./assets/logo.png" || "https://raw.githubusercontent.com/DinoscapeProgramming/Remote-Control/main/server/assets/logo.svg",
  directory: "./assets/docs" || "https://raw.githubusercontent.com/DinoscapeProgramming/Remote-Control/main/server/assets/favicon.ico"
}));

Additional options include: | Optional Parameter | | --- | | 🥷 Security (Content Security Policy) | | 🧭 Analytics | | 📲 Custom Markdown Parser | | 🎨 Custom HTML (Head or Body) | | ⏱️ Custom Code | | 👨‍💻 Custom Style | | 💱 Extensions |

app.use("/docs", expressDocs(app, {
  options: {
    security: {
      csp: `` // --> content security policy header
    },
    analytics: ``, // --> Google Analytics tracking id
    customMarkdownParser: () => {}, // --> return value in plain HTML
    customHTML: {
      head: ``,
      body: ``
    }, // --> plain HTML,
    customCode: () => {}, // --> JavaScript function
    customStyle: ``, // --> plain CSS
    extensions: [
      {
        setup: () => {}, // --> executed on function call
        middleware: () => {} // --> executed on returned function call
      }
    ]
  }
}));

The default markdown parser uses Marked and all contents of the markdown parser, no matter which, are being sanitized with DOMPurify.

Example Documentation with Dark Mode

To build and open your own installable, you'll need Node.js (which comes with npm) installed on your computer.

const express = require("express");
const app = express();
const expressDocs = require("express-docs");

app.use("/", expressDocs(app, {
  title: "Express Docs Demo",
  favicon: "./favicon.ico",
  logo: "./logo.png",
  directory: "./docs",
  options: {
    security: {
      csp: "default-src 'self'; script-src 'self' 'unsafe-inline';"
    },
    analytics: "UA-XXXXXXX-X",
    customMarkdownParser: (markdownContent) => `
      <div style="font-family: system-ui">${markdownContent}</div>
    `,
    customHTML: {
      head: `
        <meta name="description" content="Express Docs Example">
      `,
      body: `
        <div style="
          font-family: system-ui;
          position: fixed;
          right: 7.5px;
          padding-top: calc(100vh - 27.5px);
        ">Made by Express Docs</div>
     `
    },
    customCode: () => {
      console.log("This documentation page was made by Express Docs.");
    }
    customStyle: `
      body: {
        background-color: #1c1c1c;
        invert(95%) hue-rotate(180deg);
      }
    `,
    extensions: [
      require("express-docs-themes")("translucence")
    ]
  }
}));

Note If you're using Linux Bash for Windows, see this guide or use node from the command prompt.

If you're not using Windows, change the ./node_modules/express-documentation/package.json file accordingly to this guide.

Credits

This software uses the following open source packages:

Support

You may also like...

  • Remote Control - An advanced, but easy-to-use Remote Desktop Application Program
  • Youtube Offline - A lightweight YouTube video downloader
  • Appify - A tiny tool that allows you to turn your website into an app
  • Meetings - A meetings app with lots of features
  • DinoChess - A chess platform for chess lovers

License

Apache-2.0


dinoscape.com  ·  GitHub @DinoscapeProgramming  ·  Scratch @Dinoscape

1.0.81

8 months ago

1.0.80

8 months ago

1.0.77

9 months ago

1.0.76

9 months ago

1.0.75

9 months ago

1.0.74

9 months ago

1.0.79

9 months ago

1.0.78

9 months ago

1.0.73

9 months ago

1.0.72

9 months ago

1.0.71

11 months ago

1.0.69

12 months ago

1.0.68

12 months ago

1.0.67

12 months ago

1.0.66

12 months ago

1.0.65

12 months ago

1.0.64

12 months ago

1.0.63

12 months ago

1.0.62

12 months ago

1.0.61

12 months ago

1.0.60

12 months ago

1.0.59

12 months ago

1.0.58

12 months ago

1.0.57

12 months ago

1.0.56

12 months ago

1.0.55

12 months ago

1.0.54

12 months ago

1.0.53

12 months ago

1.0.52

12 months ago

1.0.51

12 months ago

1.0.50

12 months ago

1.0.49

12 months ago

1.0.48

12 months ago

1.0.47

12 months ago

1.0.46

12 months ago

1.0.45

12 months ago

1.0.44

12 months ago

1.0.43

12 months ago

1.0.42

12 months ago

1.0.41

12 months ago

1.0.40

12 months ago

1.0.39

12 months ago

1.0.38

12 months ago

1.0.37

12 months ago

1.0.36

12 months ago

1.0.35

12 months ago

1.0.34

12 months ago

1.0.33

12 months ago

1.0.32

12 months ago

1.0.31

12 months ago

1.0.30

12 months ago

1.0.29

12 months ago

1.0.28

12 months ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago