Skip to main content

SmartDoc CLI

SmartDoc CLI is a command-line tool that automatically generates Markdown, HTML, and PDF API documentation for web frameworks like FastAPI, Flask, and Django.


Installation

pip install smartdoc-cli

(For testing with Test PyPI)

pip install --index-url https://test.pypi.org/simple/ smartdoc


Usage

Run this command inside your project directory.

Example command:

smartdoc generate \
  --app your_app.main \
  --framework fastapi \
  --output api_docs.md \
  --html \
  --pdf

For FastAPI:

smartdoc generate --app your_project.main --framework fastapi --output docs.md --html --pdf

For Flask:

smartdoc generate --app your_project.main --framework flask --output docs.md --html --pdf

For Django:

smartdoc generate --app your_project.main --framework django --django-settings your_project.settings --output docs.md --html --pdf

Troubleshooting SmartDoc

If running smartdoc generate causes import/module errors, follow these steps:

Common Error:

ModuleNotFoundError: No module named 'apps'

Fix:

# For Windows PowerShell
$env:PYTHONPATH="project"
smartdoc generate --app main --framework fastapi --output api_docs.md --html --pdf

Replace main with the filename (without .py) that runs your FastAPI app.

Checkpoint Description
PYTHONPATH set? Point to folder where apps/, main.py, etc. exist
Module correct? Use --app main not full path like project.main
Inside virtualenv? Make sure .venv is activated
Imports relative? Use from apps..., not project.apps...

Tip

If you want to avoid setting PYTHONPATH every time, create a PowerShell script run_smartdoc.ps1:

$env:PYTHONPATH="project"
smartdoc generate --app main --framework fastapi --output api_docs.md --html --pdf

smartdoc.json – Custom Configuration File

Place this in your root directory (same level as .venv, your_projects, etc.):

For FastApi

{
  "app": "main",
  "framework": "fastapi",
  "output": "api_docs.md",
  "html": true,
  "pdf": true,
  "pythonpath": "project_folder"
}

For Django

{
  "app": "project_name.urls",
  "framework": "django",
  "output": "api_docs.md",
  "html": true,
  "pdf": true,
  "pythonpath": "project_name",
  "django-settings": "project_name.settings"
}

For Flask

{
  "app": "app",  // path to your Flask app file (e.g. app.py without .py)
  "framework": "flask",
  "output": "api_docs.md",
  "html": true,
  "pdf": true,
  "pythonpath": "."
}

1. Then use a custom script to run it:

Here’s a reusable Python script (run_smartdoc.py) to load from this config:

run_smartdoc.py

import os
import subprocess
import json

with open("smartdoc.json") as f:
    config = json.load(f)

os.environ["PYTHONPATH"] = config["pythonpath"]

cmd = [
    "smartdoc",
    "generate",
    "--app", config["app"],
    "--framework", config["framework"],
    "--output", config["output"]
]

if config.get("html"):
    cmd.append("--html")
if config.get("pdf"):
    cmd.append("--pdf")

subprocess.run(cmd)

Run it with: python run_smartdoc.py

Note: Additional step for Django and Flask:

1. Django

In Python Script you need to set the DJANGO_SETTINGS_MODULE environment variable.

Update run_smartdoc.py like this:

os.environ["DJANGO_SETTINGS_MODULE"] = config.get("django-settings", "")

2. Flask

In flask you only have to give the path of .py file which contains `Flask(__name__)` in the place of app.

2. Makefile (For Mac/Linux or Git Bash)

If you're on Linux/macOS or using Git Bash on Windows, you can use a Makefile.

Makefile

PYTHONPATH=your-path

generate-docs:
	PYTHONPATH=$(PYTHONPATH) smartdoc generate \
		--app main \
		--framework fastapi \
		--output api_docs.md \
		--html \
		--pdf

Run it with: make generate-docs

NOTE: Make the necessary changes for Django and Flask



CLI Options

Option Description
--app / -a Python path to your app module
--framework / -f One of fastapi, flask, django
--output / -o Output Markdown filename (default: api_docs.md)
--html Generate HTML output
--pdf Generate PDF output
--django-settings Required for Django to specify settings module

Output

Depending on options used:

api_docs.md — default markdown output

api_docs.html — HTML format (with --html)

api_docs.pdf — PDF format (with --pdf)


Author

Built with 💻 by Mohammad Safwan Athar @DevSaifOps


License

This project is licensed under the MIT License.


MIT License

Copyright (c) 2025 Mohammad Safwan Athar aka DevSaifOps

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Metadata

Release files for smartdoc-cli 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smartdoc-cli 0.1.5
File Size Uploaded Provenance
smartdoc_cli-0.1.5.tar.gz 10.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for smartdoc-cli 0.1.5
File Interpreter ABI Platform
smartdoc_cli-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 21.1 kB

Release files / smartdoc_cli-0.1.5.tar.gz

Download URL smartdoc_cli-0.1.5.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4d3941be563c14b162c767c875c0323e6a68287ae83c5106327a0ec3d0897cd7
BLAKE2b-256 checksum
How to use checksums
cb7983a62a1bb4cf0370694d9c0843221ea6831efe17a9fc1eb80fecc10fa546
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Release files / smartdoc_cli-0.1.5-py3-none-any.whl

Download URL smartdoc_cli-0.1.5-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee76d9bda408e999b01ad0f615df4ad9eb16c3fb54dc7308936db15824b62a0a
BLAKE2b-256 checksum
How to use checksums
0c279bc2bf18ac5091eb3cb1481da8465cc1840633330b139369c9eb33343b5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Security for smartdoc-cli 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page