Files
backstage/packages/techdocs-cli
Emma Indal 21d4ee819f Docs updates
Signed-off-by: Emma Indal <emma.indahl@gmail.com>

Co-authored-by: Bodil Björklund <bodilb@spotify.com>
2022-02-17 14:22:19 +01:00
..
2022-02-17 14:22:18 +01:00
2021-11-21 09:39:02 -05:00
2022-02-17 10:38:59 +00:00
2022-02-17 14:22:18 +01:00
2022-02-17 14:22:18 +01:00
2022-02-17 14:22:19 +01:00

techdocs-cli

NPM Version badge

Usage

See techdocs-cli usage docs.

Development

NOTE: When we build techdocs-cli it copies the output techdocs-cli-embedded-app bundle into the packages/techdocs-cli/dist which is then published with the @techdocs/cli npm package.

Running

# From the root of this repository run
# NOTE: This will build the techdocs-cli-embedded-app and copy the output into the cli dist directory
yarn build --scope @techdocs/cli

# Now execute the binary
packages/techdocs-cli/bin/techdocs-cli

# ... or as a shell alias in ~/.zshrc or ~/.zprofile or ~/.bashrc or similar
export PATH=/path/to/backstage/packages/techdocs-cli/bin:$PATH

If you want to test live test changes to the packages/techdocs-cli-embedded-app you can serve the app and run the CLI using the following commands:

# Open a shell to the techdocs-cli-embedded-app directory
cd packages/techdocs-cli-embedded-app

# Run the techdocs-cli-embedded-app using dev mode
yarn start

# In another shell use the techdocs-cli from the root of this repo
yarn techdocs-cli:dev [...options]

Using an example docs project

For the purpose of local development, we have created an example documentation project which is shipped with the techdocs-container repository. You are of course also free to create your own local test site - all it takes is a docs/index.md and an mkdocs.yml in a directory.

git clone https://github.com/backstage/techdocs-container.git

cd techdocs-container/mock-docs

# To get a view of your docs in Backstage, use:
techdocs-cli serve

# To view the raw mkdocs site (without Backstage), use:
techdocs-cli serve:mkdocs

Testing

Running unit tests requires mkdocs to be installed locally:

pip install mkdocs
pip install mkdocs-techdocs-core

Then run yarn test.

Running Cypress tests

Running cypress tests requires you to run the CLI locally against our example docs project.

Start by making sure that you have the example project locally on your computer:

git clone https://github.com/backstage/techdocs-container.git

Run the local version of techdocs-cli against the example docs project:

# From the root of this repository run
# NOTE: This will build the techdocs-cli-embedded-app and copy the output into the cli dist directory
yarn build --scope @techdocs/cli

# Navigate to the example project
cd techdocs-container/mock-docs

# Now execute the techdocs-cli serve command
../../backstage/packages/techdocs-cli/bin/techdocs-cli serve

Run the cypress tests:

yarn cypress:open

If its the first time you run Cypress, it will run a "Verifying Cypress can run" step. This step can result in a "Cypress verification timed out" error. If that is the case, let the verification step run and then run the command again and it should succeed.