Simple generator of gitlab ci file documentation
Project description
Motivation
Let's assume the design when we want to trigger a pipeline from web UI or by an API call. The pipeline consumes variables as input. It would be very helpful to know the type of a variable or its valid options. This kind of information is usually part of the documentation. This package provides functionality to automate the creation of this documentation.
Overview
The output of this script is simple description (documentation) of workflow section. It parses workflow section and inserts it to readme file. Currently, output documentation is only as html table.
Properties of variables are defined in comment using the format described in following section.
Variable definition
As mentioned before, we write all parameters of a variable to a comment. Format of a comment is very simple.
- first part describes if variable is required on input. By default a variable is considered as optional. To "set" is as required, put required to the comment - # required
- second part descibes variable's type or valid options.
- type - starts with colon. Typename can be whatever made up. :type
- choices - dev|test
These parts are separated by space. Type and choices must not by combined.
Example
ENV: dev # required dev|test|prod
ACCOUNT_ALIAS: null # required :str
IMAGE_TAG: 0.1.0 # :version
Pipeline name
Using of the pipeline name improves readability of pipeline runs and also describes the task executed by the pipeline.
Variable PIPELINE_NAME is showed in the separated column of the table.
Usage
The tool can be used from command line or imported as module in a code. Output is written to the readme file.
Insert to the Readme
By default, the script inserts generated table in the beggining of the file. However, it is possible to mark position in the file where the table will be inserted. The mark token is
<!--PIPELINE_DOCS-->
If token is present, the table is insreted below it.
Command line
The package gitlabcidocs consumes following arguments:
- --ci-file [optional]
- Path to the file containing workflow section.
- Default value is .gitlab-ci.yml
- --doc-file [optional]
- Path to the output file.
- Default value is README.md
- --include-all-rules, -a [optional]
- If set to *true*, all rules in the workflow section are included. Otherwise only rules which includes $CI_PIPELINE_SOURCE==web|api|pipeline in the if statement are documented.
- Default is true
- --include-global-vars, -g [optional]
- If set, global variables section is included.
- Default value is false
python -m gitlabcidocs --ci-file my_workflow.yml --doc-file myREADME.md
Import in code
The module gitlab-ci-docs contains create_docs function. The functions consumes the same arguments as cli tool, but there are no default values set.
import gitlabcidocs
def run_create_docs():
docs = gitlabcidocs.create_docs(
ci_file_path='my_workflow.yml',
docs_file_path='README.md'
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gitlab_ci_docs-0.1.0b3.tar.gz
.
File metadata
- Download URL: gitlab_ci_docs-0.1.0b3.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16589a15a4d939675cfbce87b32231a451bc642c54dafcf4273158c005dd7c46 |
|
MD5 | b5a6167dd157efbf5d2a8d07db1b719d |
|
BLAKE2b-256 | cb4efa6ee71b818ae3fa857a8e088caed19acd175655afebfa58f7897805e612 |
File details
Details for the file gitlab_ci_docs-0.1.0b3-py3-none-any.whl
.
File metadata
- Download URL: gitlab_ci_docs-0.1.0b3-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15f7a4f9ace8d44c262a0de710301846ffd1ebdcd899e581cbcf653098f5b865 |
|
MD5 | e1f2c4bf001f091d649db4f802112568 |
|
BLAKE2b-256 | 82ad449b51a36e32910c8b639c4b6a3f1baf8e204923df5c9fbd23b762aeacad |