Mosheh, automatic and elegant documentation of Python code with MkDocs.
Project description
Mosheh
Mosheh, automatic and elegant documentation of Python code with MkDocs.
Inspirated by cargodoc - a Rust tool for code documenting - and using MkDocs + Material MkDocs, Mosheh is an easy, fast, plug-and-play tool which saves time while automating the process of documenting the source code of a Python codebase.
| Project/Codebase | PLoC | Mosheh's Exec Time | |
|---|---|---|---|
| Mosheh | ~4k | 0.303s | |
| scikit-learn | ~862k | ███████████ | 11.783s |
| NumPy | ~204k | ████████████ | 12.205 |
PLoC: Python Lines of Code
Specs: Mint 21.3 | Aspire A515-54 | Intel i7-10510U (8) @ 4.900GHz | RAM 19817MiB
This is not an alternative to MkDocs, but a complement based on it, since Mosheh lists all files you points to, saves every single notorious definition statement on each file iterated, all using Python ast native module for handling the AST and then generating a modern documentation respecting the dirs and files hierarchy.
At the moment, Mosheh documents only Python files (.py, .pyi), where the stuff documented for each file is shown below:
-
Imports
ast.Import | ast.ImportFrom- Type
Native | TrdParty | Local - Path (e.g.
math.sqrt) - Code
- Type
-
Constants
ast.Assign | ast.AnnAssign- Name (token name)
- Typing Annotation (datatype)
- Value (literal or call)
- Code
-
Classes
ast.ClassDef- Description (docstring)
- Name (class name)
- Parents (inheritance)
- Methods Defined (nums and names)
- Code
-
Funcs
ast.FunctionDef | ast.AsyncFunctionDef- Description (docstring)
- Name (func name)
- Type
Func | Method | Generator | Coroutine - Parameters (name, type, default)
- Return Type (datatype)
- Raises (exception throw)
- Code
-
Assertions
ast.Assert- Test (assertion by itself)
- Message (opt. message in fail case)
- Code
Stack
Contributing
Before getting access to the To-Do List, Coding Style or even forking the project, we strongly recommend reading Mosheh's Guidelines
Arch
Mosheh's architecture can be interpreted in two ways: the directory structure and the interaction of the elements that make it up. A considerable part of a project is - or at least should be - that elements that are dispensable for its functionality are in fact dispensable, such as the existence of automated tests; they are important so that any existing quality process is kept to a minimum acceptable level, but if all the tests are deleted, the tool still works.
Here it is no different, a considerable part of Mosheh is, in fact, completely dispensable; follow below the structure of directories and relevant files that are part of this project:
.
├── mosheh/ # Mosheh's source-code
│ ├── commands/* # Logics for each command
│ ├── handlers/* # Codebase handlers for each file
│ ├── doc/* # Documentation build logics
│ ├── types/ # Custom data types
│ │ ├── basic.py # Basic types (e.g. "type Token = str")
│ │ ├── contracts.py # Contracts to ensure correct typing
│ │ ├── enums.py # Enums for standardizing assignments
│ │ └── jsoncfg.py # JSON for structuring commands config
│ ├── codebase.py # Codebase reading logic
│ ├── constants.py # Constants to be evaluated
│ ├── main.py # Entrypoint
│ └── utils.py # Utilities
│
├── tests/ # Template dir for testing
│ ├── DOC # Doc output dir
│ ├── PROJECT # Template project dir
│ └── unittest # Automated tests
│
├── documentation/ # Mosheh's documentation dir
│ ├── docs/ # Dir containing .md files and assets
│ ├── mkdocs.yml # MkDocs's config file
│ └── mosheh.json # Mosheh's exec config file
│
├── pyproject.toml # Mosheh's config file for almost everything
├── uv.lock # uv's lockfile for dealing with dependencies
├── .python-version # Default Python's version to use
│
├── .github/ # Workflows and social stuff
│
├── LICENSE # Legal stuff, A.K.A donut sue me
│
└── .gitignore # Git "exclude" file
It is to be expected that if the tests/ directory is deleted, Mosheh's core will not be altered in any way, so much so that when a tool is downloaded via pip or similar, the tool is not accompanied by tests, licenses, development configuration files or workflows. So, to help you understand how the mosheh/ directory works, here's how the functional elements interact with each other:
Usage
After installing Mosheh as a development dependency, create the documentation folder if not exists and run mosheh init [--path .]; this will result in a mosheh.json config file just as below:
{
"documentation": {
"projectName": "Mosheh",
"repoName": "mosheh",
"repoUrl": "https://github.com/lucasgoncsilva/mosheh",
"editUri": "blob/main/documentation/docs",
"siteUrl": "https://lucasgoncsilva.github.io/mosheh/",
"logoPath": "./path/to/logo.svg",
"readmePath": "./path/to/README.md",
"codebaseNavPath": "Codebase"
},
"io": {
"rootDir": "./app/",
"outputDir": "./path/to/output/"
}
}
After making sure the data on that JSON reflects the desired (more about this file at the official documentation), running mosheh create [--json .] results in a documentation following the default MkDocs structure with Material MkDocs as theme, with the codebase documented over "Codebase" named-section.
Development
Installing Dependencies
# Automatically handles everything with .venv
uv sync
Running Locally
# For running using uv and dealing with Mosheh as a module
uv run mosheh -h
Building Locally
# Build pip-like file
uv build
Testing
# Run all the testing workflow
uv run task test
Lint
# Run all the linting workflow
uv run task lint
Generate Self Document
# Generate Mosheh's Codebase Documentation
uv run task makedoc
License
This project is under MIT License. A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.
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 mosheh-2.0.1.tar.gz.
File metadata
- Download URL: mosheh-2.0.1.tar.gz
- Upload date:
- Size: 767.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce449bc5b595c48fb1e8750eb5d2858d887c0e87237fb017edf9fe958af63235
|
|
| MD5 |
d49538eae4ed69e3f0a82bfd5eaaf09a
|
|
| BLAKE2b-256 |
58a6b1fe78f362f57e1a2bb85eefb9cff98c4d54ff075c4126614809147d26b3
|
File details
Details for the file mosheh-2.0.1-py3-none-any.whl.
File metadata
- Download URL: mosheh-2.0.1-py3-none-any.whl
- Upload date:
- Size: 43.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71a07df926b775d321da45dba691490f867d0fa377bddc09e6004d2935ce9fa4
|
|
| MD5 |
c7148b8f48d9509887ae8cf7b139d278
|
|
| BLAKE2b-256 |
d83d17f77cdd8cdcd25c5f7d722b070de4c740a16387bcc4f835ce239bd0e4d6
|