Getting Started
This documentation is intended to serve as the place to record the processes, preferences, and code conventions used by the organization.
You can explore the documentation from the sidebar.
✍️ Contributing
Section titled “✍️ Contributing”The docs use Astro Starlight for documentation.
This doc will only cover the specifics of the WiMetrix docs, and not how Starlight works.
Read the Starlight docs to learn about how to use it.
The documents are written in MDX, an extension of markdown that supports JSX syntax and breaking files into logical chunks.
There are 2 ways to contribute new content to the docs:
-
Recommended
Use Visual Studio Code. - Live preview - Automatic formatting - Autocomplete and AI suggestions - Syntax highlighting - Spellcheck
-
Use a markdown GUI to create the document and then copy the contents to the
src/content/docsfolder.StackEdit is a web based markdown editor that can be used for this.
🚀 Setup
Section titled “🚀 Setup”-
Install Visual Studio Code. (Download here)
-
Install the following VSCode extensions:

-
Clone this repository.
-
Run the install script to setup the dev environment.
Terminal window ./install.shRun the following command in an elevated command line:
Terminal window ./install.batOr
Right click on
./install.batand Run as Administrator. -
If not windows, run
./install.shin the terminal. -
Start the development server.
Terminal window pnpm dev -
Open the site in your browser at
localhost:4321. Adding or updating documents should automatically show the changes in the browser.
🧞 Commands
Section titled “🧞 Commands”All commands are run from the root of the project, from a terminal:
| Command | Action |
|---|---|
pnpm install | Installs dependencies |
pnpm dev | Starts local dev server at localhost:4321 |
pnpm build | Build your production site to ./dist/ |
pnpm preview | Preview your build locally, before deploying |
pnpm astro ... | Run CLI commands like astro add, astro check |
pnpm astro -- --help | Get help using the Astro CLI |
📂 Folder Structure
Section titled “📂 Folder Structure”Directorypublic
- …
Directorysrc
- assets
Directorycontent
Directorydocs
- …
- config.ts
- …
- astro.config.mjs
- package.json
- tsconfig.json
- …
Starlight picks up .md or .mdx files in the src/content/docs/ directory.
Images and other assets can be colocated in the same folder as the .md or .mdx file, and linked using a relative path.
Shared assets (used by multiple docs) can be added to src/assets/.
Static assets, like favicons or files, are placed in the public/ directory.
While the content folder structure and file names is not enforced, consistent structure makes content easier to navigate and find.
📄 Naming conventions
Section titled “📄 Naming conventions”It is recommended to follow the following conventions:
- Use kebab-case for file and folder names
- Use lowercase alphabet.
- Use dashes
-to separate words in file names.
- Folder structure should correspond to the content hierarchy.
- Create a folder for each page, to colocate assets.
- Store page assets in the
assetsfolder inside the page folder. - Add the page to the sidebar by updating the
./sidebar.mjsfile
📝 Adding Content
Section titled “📝 Adding Content”Content is stored in the src/content/docs directory as markdown files.
Each mdx has metadata at the top of the file, which is used to generate the page.
Common metadata includes:
title: The title of the page.description: A short description of the page.slug: The URL of the page.sidebar(optional): Overrides the default sidebar setting for the page.sidebar.label: The label to display in the sidebar.titleis used by default.
For example, when creating reference for a module named Bar of the Foo product, do the following:
-
Create a folder at
src/content/docs/products/bar/foo(Create any folder in the path that doesn’t exist).
-
Create a file called
foo.mdxin the new folder. -
Add the metadata to the top of the file.
---title: "Bar Module"description: Overview of the Bar module of the Foo Productsidebar: { label: "Bar" }slug: products/foo/bar--- -
Add the page to the sidebar in
./sidebar.mjsSidebar entries can be route path strings, or detailed config objects. Check the starlight docs for more info.
export const sidebar = [...{label: "Products",collapsed: true,items: [...{label: "Foo",collapsed: true,items: ["products/foo","products/foo/bar",],},],},]; -
The page should show in the sidebar. You can now add content to the page.
🏗️ Assets
Section titled “🏗️ Assets”Like stated above, images and other assets should be colocated in the same folder as the content file, and linked using a relative path.
If an asset needs to be referenced from multiple places, it should be added to src/assets/.
The image assets are automatically optimized by Astro at build time.
However the image assets should be optimized manually before committing, to reduce the size of the repository.
TinyPNG can be used to optimize the images.
Mermaid Diagrams
Section titled “Mermaid Diagrams”Mermaid diagrams are supported natively, and can be added in a markdown codeblock directly.
Example:
```mermaid%%{ init: {"theme": "forest"} }%%
flowchart TD A[Node A] -->|A to B| B{Node B}```This will be rendered as:
Generating Mermaid ERD from DB
Section titled “Generating Mermaid ERD from DB”Mermerd is used to automatically generate ERDs from DB tables.
ERD is generated as a Mermaid diagram in a markdown file.
The script at db/gen-erd.sh is used to generate the file.
While complex and large ERD diagrams may not be suitable for automatic generation due to the size of the diagram, simpler diagrams can be generated automatically.
-
Create a config file in the
dbfolder.The config file should be named after the ERD file, and end with
.yaml.For example, if the ERD file is named
carton-audit.md, the config file should be namedcarton-audit.yaml. -
Add a script to
package.jsonthat invokes thegen-erd.shscript.- Generate the erd file in the same folder as the content file.
- The generated
.mdfilename should be prefixed with and underscore (_). This will make sure Starlight will not pick it up as a content file.
{..."scripts": {..."gen:erd:<name>": "./db/gen-erd.sh ./db/<name>.yaml <output-path>.md",}} -
Run the script to generate the file.
Terminal window pnpm gen:erd:<name> -
Link the generated file in the content file.
The file must be an
.mdxfile, and not a.mdfile.import Erd from "<path>.md";<Erd />
Creating Screenshots and Diagrams
Section titled “Creating Screenshots and Diagrams”Screenshots and diagrams can be created using Figma.
Use this figma file to create diagrams and screenshots.
📥 Generating PDF
Section titled “📥 Generating PDF”Starlight to PDF is used to generate PDF files from the content pages.
-
Add a script file to the
pdffolder.The script is a
mjsfile.Use the
generatePdffunction from thepdf/pdf.mjsfile.The function takes the following parameters:
-
path: The base route path of the docs website.(
productsmeanshttps://docs.wimetrix.com/productswill be the base path) -
fileName: The path of the output pdf file. -
depth: An optional number of levels to include in the PDF.Using depth of
2with pathproductsfor example meansproducts, andproducts/pack-and-shipwill be included, butproducts/spts/sewingwill be excluded.All matched routes are included if not provided.
-
routes: An optional array of route paths to include in the PDF.["guides", "guides/odoo"]will only include the routesguidesandguides/odoo. All other routes will be excluded.All matched routes are included if not provided.
import { generatePdf } from "./pdf.mjs";generatePdf({baseUrl: "https://docs.wimetrix.com",path: "products/foo",fileName: "foo",routes: ["products/foo", "products/foo/bar"],}); -
-
Add a script to the
package.jsonfile.{..."scripts": {..."gen:pdf:foo": "node ./pdf/gen-foo.mjs",}} -
Run the script to generate the PDF.
Terminal window pnpm gen:pdf:foo