Skip to content

Commit b8b2faa

Browse files
committed
Add ma docs command
1 parent 78a87b0 commit b8b2faa

File tree

7 files changed

+56
-1
lines changed

7 files changed

+56
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# makeapp changelog
22

33

4+
### Unreleased
5+
* ++ Add 'ma docs' command.
6+
47
### v2.0.0 [2025-10-04]
58
* !! Big rewrite. Now uses up-to-date conventions and technologies.
69
* ++ Add 'ma' alias for 'makeapp' command.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ https://github.com/idlesign/makeapp
1919
* Easily add entries to your changelog.
2020
* Publish your application to remotes (VCS, PyPI) with a single command.
2121
* Easily bootstrap your development environment.
22+
* Build and local serve the docs.
2223
* Run code styling/linting.
2324

2425
## Application scaffolding
@@ -94,6 +95,15 @@ Apply code style with `style` command:
9495
ma style
9596
```
9697

98+
99+
## Build/serve docs
100+
101+
Use `docs` command:
102+
103+
``` bash
104+
ma docs
105+
```
106+
97107
## Documentation
98108

99109
https://makeapp.readthedocs.io/

docs/040_development.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ To style/lint your code use the following command:
3838
```bash
3939
ma style
4040
```
41+
42+
## Build/serve docs
43+
44+
Use `docs` command:
45+
46+
``` bash
47+
ma docs
48+
```

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Easily add entries to your changelog.
1515
* Publish your application to remotes (VCS, PyPI) with single command.
1616
* Easily bootstrap your development environment.
17+
* Build and local serve the docs.
1718
* Run code styling/linting.
1819

1920

src/makeapp/apptools.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .helpers.files import FileHelper
99
from .helpers.vcs import VcsHelper
1010
from .helpers.venvs import VenvHelper
11-
from .utils import chdir, configure_logging, Uv, Ruff
11+
from .utils import chdir, configure_logging, Uv, Ruff, MkDocs
1212

1313
LOG = logging.getLogger(__name__)
1414

@@ -510,6 +510,10 @@ def style(self):
510510
LOG.info('Styling ...')
511511
Ruff.check()
512512

513+
def docs(self, *, serve: bool = True):
514+
LOG.info('Making docs ...')
515+
MkDocs.serve() if serve else MkDocs.build()
516+
513517
def venv_init(self, *, reset: bool = False, register_tool: bool = False):
514518
self.venv.initialize(reset=reset)
515519

src/makeapp/cli.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,19 @@ def style(debug):
234234
click.secho('Done', fg='green')
235235

236236

237+
@entry_point.command()
238+
@option_debug
239+
@click.option(
240+
'-b', '--build',
241+
help='Build only. Do not serve', is_flag=True
242+
)
243+
def docs(debug, build):
244+
"""Build/serve documentation."""
245+
project = Project(log_level=logging.DEBUG if debug else logging.INFO)
246+
project.docs(serve=not build)
247+
click.secho('Done', fg='green')
248+
249+
237250
def main():
238251
try:
239252
entry_point(obj={})

src/makeapp/utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ def check(cls, fix: bool = True) -> list[str]:
163163
return cls._run(f'check{" --fix" if fix else ""}')
164164

165165

166+
class MkDocs:
167+
"""MkDocs wrapper."""
168+
169+
@classmethod
170+
def _run(cls, cmd: str) -> list[str]:
171+
return run_command(f'mkdocs {cmd}', capture=False)
172+
173+
@classmethod
174+
def serve(cls) -> list[str]:
175+
return cls._run('serve -o')
176+
177+
@classmethod
178+
def build(cls) -> list[str]:
179+
return cls._run('build')
180+
181+
166182
class Uv:
167183
"""Uv wrapper."""
168184

0 commit comments

Comments
 (0)