A simple automatic Dockerfile documentation generator
Project description
Docks: Easy Dockerfile Documentation Generator 📜🐳
docks is a Python framework designed to generate Markdown documentation for your Dockerfiles. It extracts key elements such as base images, ARG/ENV variables, exposed ports, and copied/added files, producing clear, structured documentation.
Features ✨
- Extracts:
- Base Images (
FROM) - ARG/ENV Variables with optional docstrings and references
- Exposed Ports with descriptions
- Copied/Added Files (
COPY/ADD) with context
- Base Images (
- Outputs clean Markdown documentation for your Dockerfiles.
- Easy to use, modular, and extensible.
Installation 🚀
Install docks via Poetry or pip:
Using Poetry
poetry add docks
Using Pip
pip install docks
Usage 🛠️
Via CLI
The docks CLI allows you to quickly generate Markdown documentation for a Dockerfile without writing code.
Here is all you have to do in order to generate the documentation.
docks <dockerfile> <output>
# e.g.
# docks myproject/Dockerfile myproject/dockerfile-doc.md
CLI Arguments
dockerfile: Path to the Dockerfile to document.output: Path to save the generated Markdown documentation.
Via Python
You can also easily create the documentation programmatically via Python.
Example: Generate Documentation from a Dockerfile
- Ensure you have a valid Dockerfile in your project.
- Run the following Python script
from docks.generate_doc import generate_markdown
# Path to your Dockerfile
dockerfile_path = "Dockerfile"
# Output Markdown file
output_path = "README.md"
# Generate documentation
generate_markdown(dockerfile_path, output_path)
Dockerfile Docstring Convention 📝
ARG/ENV Variables
- Include a block comment directly above the variable.
- Start the comment with the variable name followed by
:for docstring extraction. - Optionally include a reference using
@ref:.
Example
# MY_VAR: Description of the variable.
# @ref: https://example.com/docs
ARG MY_VAR=default
EXPOSE Ports
Include a comment directly above the EXPOSE command.
Start with the port number followed by : for the description.
Example
# 8080: Main HTTP server port
EXPOSE 8080
COPY/ADD Files
Add a comment directly above the COPY or ADD command for context.
Example
# Copy application code to the container
COPY src/ /app/
Testing ✅
Run tests with pytest:
pytest tests/
Contributing 🤝
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/<FEATURE_NAME>. - Commit your changes:
git commit -m "Add feature". - Push the branch:
git push origin feature/<FEATURE_NAME>. - Open a pull request.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docks-0.1.11.tar.gz.
File metadata
- Download URL: docks-0.1.11.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8eb1ecfa8687cd2f4dd70ef3e25e2fe65f7c79eb2ee37428bc93989cb4c5853
|
|
| MD5 |
a7de2dd70964a4f8dde765b36f34eb27
|
|
| BLAKE2b-256 |
bc45ca84560bad0ab32c37c9b4bd68c546d5bd1e70678d423e130e2917da48b6
|
File details
Details for the file docks-0.1.11-py3-none-any.whl.
File metadata
- Download URL: docks-0.1.11-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7afd00f4ca0435b9e937de57f05dac42afc0c9f703e4969515c798694e11e6f0
|
|
| MD5 |
1ef3e3fb6e20777d077686b3b887bf8a
|
|
| BLAKE2b-256 |
4560fc7710cc22bb5cc41d06138fb69c8024ee54bdcdf8dc92a95a95b074679c
|