This documentation is for a release that is no longer maintained
See documentation for the latest supported version.Chapter 6. Configuring TechDocs
Configure the Red Hat Developer Hub TechDocs plugin to create, find, and use documentation in a central location and in a standardized way. For example:
- Docs-like-code approach
- Write your technical documentation in Markdown files that are stored inside your project repository along with your code.
- Documentation site generation
- Use MkDocs to create a full-featured, Markdown-based, static HTML site for your documentation that is rendered centrally in Developer Hub.
- Documentation site metadata and integrations
- See additional metadata about the documentation site alongside the static documentation, such as the date of the last update, the site owner, top contributors, open GitHub issues, Slack support channels, and Stack Overflow Enterprise tags.
- Built-in navigation and search
- Find the information that you want from a document more quickly and easily.
- Add-ons
- Customize your TechDocs experience with Add-ons to address higher-order documentation needs.
The TechDocs plugin is preinstalled and enabled on a Developer Hub instance by default. You can disable or enable the TechDocs plugin, and change other parameters, by configuring the Red Hat Developer Hub Helm chart or the Red Hat Developer Hub Operator config map.
Red Hat Developer Hub includes a built-in TechDocs builder that generates static HTML documentation from your codebase. However, the default basic setup of the local builder is not intended for production.
You can use a CI/CD pipeline with the repository that has a dedicated job to generate docs for TechDocs. The generated static files are stored in OpenShift Data Foundation or in a cloud storage solution of your choice and published to a static HTML documentation site.
After you configure OpenShift Data Foundation to store the files that TechDocs generates, you can configure the TechDocs plugin to use the OpenShift Data Foundation for cloud storage.
6.1. Configuring storage for TechDocs files Copy linkLink copied to clipboard!
The TechDocs publisher stores generated files in local storage or in cloud storage, such as OpenShift Data Foundation, Google GCS, AWS S3, or Azure Blob Storage.
6.1.1. Using OpenShift Data Foundation for file storage Copy linkLink copied to clipboard!
You can configure OpenShift Data Foundation to store the files that TechDocs generates instead of relying on other cloud storage solutions.
OpenShift Data Foundation provides an ObjectBucketClaim custom resource (CR) that you can use to request an S3 compatible bucket backend. You must install the OpenShift Data Foundation Operator to use this feature.
Prerequisites
- An OpenShift Container Platform administrator has installed the OpenShift Data Foundation Operator in Red Hat OpenShift Container Platform. For more information, see OpenShift Container Platform - Installing Red Hat OpenShift Data Foundation Operator.
-
An OpenShift Container Platform administrator has created an OpenShift Data Foundation cluster and configured the
StorageSystemschema. For more information, see OpenShift Container Platform - Creating an OpenShift Data Foundation cluster.
Procedure
Create an
ObjectBucketClaimCR where the generated TechDocs files are stored. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteCreating the Developer Hub
ObjectBucketClaimCR automatically creates both the Developer HubObjectBucketClaimconfig map and secret. The config map and secret have the same name as theObjectBucketClaimCR.
After you create the ObjectBucketClaim CR, you can use the information stored in the config map and secret to make the information accessible to the Developer Hub container as environment variables. Depending on the method that you used to install Developer Hub, you add the access information to either the Red Hat Developer Hub Helm chart or Operator configuration.
6.1.2. Making object storage accessible to containers by using the Helm chart Copy linkLink copied to clipboard!
Creating a ObjectBucketClaim custom resource (CR) automatically generates both the Developer Hub ObjectBucketClaim config map and secret. The config map and secret contain ObjectBucket access information. Adding the access information to the Helm chart configuration makes it accessible to the Developer Hub container by adding the following environment variables to the container:
-
BUCKET_NAME -
BUCKET_HOST -
BUCKET_PORT -
BUCKET_REGION -
BUCKET_SUBREGION -
AWS_ACCESS_KEY_ID -
AWS_SECRET_ACCESS_KEY
These variables are then used in the TechDocs plugin configuration.
Prerequisites
- You have installed Red Hat Developer Hub on OpenShift Container Platform using the Helm chart.
-
You have created an
ObjectBucketClaimCR for storing files generated by TechDocs. For more information see Using OpenShift Data Foundation for file storage
Procedure
In the
upstream.backstagekey in the Helm chart values, enter the name of the Developer HubObjectBucketClaimsecret as the value for theextraEnvVarsSecretsfield and theextraEnvVarsCMfield. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.1.2.1. Example TechDocs Plugin configuration for the Helm chart Copy linkLink copied to clipboard!
The following example shows a Developer Hub Helm chart configuration for the TechDocs plugin:
6.1.3. Making object storage accessible to containers by using the Operator Copy linkLink copied to clipboard!
Creating a ObjectBucketClaim custom resource (CR) automatically generates both the Developer Hub ObjectBucketClaim config map and secret. The config map and secret contain ObjectBucket access information. Adding the access information to the Operator configuration makes it accessible to the Developer Hub container by adding the following environment variables to the container:
-
BUCKET_NAME -
BUCKET_HOST -
BUCKET_PORT -
BUCKET_REGION -
BUCKET_SUBREGION -
AWS_ACCESS_KEY_ID -
AWS_SECRET_ACCESS_KEY
These variables are then used in the TechDocs plugin configuration.
Prerequisites
- You have installed Red Hat Developer Hub on OpenShift Container Platform using the Operator.
-
You have created an
ObjectBucketClaimCR for storing files generated by TechDocs.
Procedure
In your
BackstageCR, enter the name of the Developer HubObjectBucketClaimconfig map as the value for thespec.application.extraEnvs.configMapsfield and enter the Developer HubObjectBucketClaimsecret name as the value for thespec.application.extraEnvs.secretsfield. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.1.3.1. Example TechDocs Plugin configuration for the Operator Copy linkLink copied to clipboard!
The following example shows a Red Hat Developer Hub Operator config map configuration for the TechDocs plugin:
6.2. Configuring CI/CD to generate and publish TechDocs sites Copy linkLink copied to clipboard!
TechDocs reads the static generated documentation files from a cloud storage bucket, such as OpenShift Data Foundation. The documentation site is generated on the CI/CD workflow associated with the repository containing the documentation files. You can generate docs on CI and publish to a cloud storage using the techdocs-cli CLI tool.
You can use the following example to create a script for TechDocs publication:
The TechDocs workflow starts the CI when a user makes changes in the repository containing the documentation files. You can configure the workflow to start only when files inside the docs/ directory or mkdocs.yml are changed.
6.2.1. Preparing your repository for CI Copy linkLink copied to clipboard!
The first step on the CI is to clone your documentation source repository in a working directory.
Procedure
To clone your documentation source repository in a working directory, enter the following command:
git clone <https://path/to/docs-repository/>
git clone <https://path/to/docs-repository/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.2.2. Generating the TechDocs site Copy linkLink copied to clipboard!
Procedure
To configure CI/CD to generate your techdocs, complete the following steps:
Install the
npxpackage to runtechdocs-cliusing the following command:npm install -g npx
npm install -g npxCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install the
techdocs-clitool using the following command:npm install -g @techdocs/cli
npm install -g @techdocs/cliCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install the
mkdocsplugins using the following command:pip install "mkdocs-techdocs-core==1.*"
pip install "mkdocs-techdocs-core==1.*"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate your techdocs site using the following command:
npx @techdocs/cli generate --no-docker --source-dir <path_to_repo> --output-dir ./site
npx @techdocs/cli generate --no-docker --source-dir <path_to_repo> --output-dir ./siteCopy to Clipboard Copied! Toggle word wrap Toggle overflow Where
<path_to_repo>is the location in the file path that you used to clone your repository.
6.2.3. Publishing the TechDocs site Copy linkLink copied to clipboard!
Procedure
To publish your techdocs site, complete the following steps:
- Set the necessary authentication environment variables for your cloud storage provider.
Publish your techdocs using the following command:
npx @techdocs/cli publish --publisher-type <awsS3|googleGcs> --storage-name <bucket/container> --entity <namespace/kind/name> --directory ./site
npx @techdocs/cli publish --publisher-type <awsS3|googleGcs> --storage-name <bucket/container> --entity <namespace/kind/name> --directory ./siteCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add a
.github/workflows/techdocs.ymlfile in your Software Template(s). For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow