Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start adding real documentation, and publish it to readthedocs #297

Merged
merged 2 commits into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions bork/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
"""Command-line interface for Bork.

General usage: `bork COMMAND [OPTIONS] [ARGS]`

Options that exist for all commands include:

`--verbose`: enable verbose logging

`--debug`: enable even more verbose logging (sometimes too noisy to be helpful)

## Commands

<dl>
"""

import inspect
import logging
import os
Expand All @@ -21,6 +36,11 @@ def cli():

@cli.command()
def aliases():
"""
### `bork aliases`

Prints a list of aliases (configured via pyproject.toml).
"""
alias_list = api.aliases()
if len(alias_list.keys()) == 0:
print('No aliases available.')
Expand All @@ -32,18 +52,33 @@ def aliases():

@cli.command()
def build():
"""
### `bork build`

Build the project.
"""
api.build()


@cli.command()
def clean():
"""
### `bork clean`

Remove files created by `bork build`.
"""
api.clean()


@cli.command()
@click.option('-o', '--output', type=click.File('w'), default='-',
help='File in which to save the list of dependencies.')
def dependencies(output):
"""
### `bork dependencies`

List dependencies of the project.
"""
for dep in api.dependencies():
print(dep, file=output)

Expand All @@ -57,6 +92,26 @@ def dependencies(output):
@click.argument('package', nargs=1)
@click.argument('release_tag', nargs=1, default='latest')
def download(files, directory, package, release_tag):
"""
### `bork download [--files FILES] [--directory DIRECTORY] PACKAGE RELEASE`

Download a release of the specified project.

Arguments:
--files=FILES:
(default `*.pyz`)
A comma-separated list of filenames to download.
Supports wildcards (* = everything, ? = any single character).
--directory=DIRECTORY:
(default `downloads`)
The directory to save files in. Created if missing.
PACKAGE:
The package to download. Of the format `SOURCE:PACKAGE_NAME`, where
`PACKAGE_NAME` is the name of the package to download, and `SOURCE`
is one of `gh`, `github`, `pypi`, or `testpypi`.
RELEASE:
The release or tag of the package that you want to download.
"""
# NOTE: We change the order of the arguments here, to move away from
# what makes sense on a CLI interface to what makes sense in a
# Python interface.
Expand All @@ -76,6 +131,21 @@ def download(files, directory, package, release_tag):
@click.option('--dry-run', is_flag=True, default=False,
help="Don't actually release, just show what a release would do.")
def release(pypi_repository, test_pypi, dry_run):
"""
### `bork release [--pypi-repository=REPO | --test-pypi] [--dry-run]`

Arguments:
--pypi-repository=REPO:
(default `pypi`)
Repository to use. Valid values are pypi, testpypi, or anything
defined in ".pypirc".

--test-pypi:
Equivalent to `--pypi-repository testpypi`

--dry-run:
Don't actually release, just show what a release would do.
"""
if test_pypi:
pypi_repository = 'testpypi'
api.release(pypi_repository, dry_run)
Expand All @@ -84,6 +154,11 @@ def release(pypi_repository, test_pypi, dry_run):
@cli.command()
@click.argument('alias', nargs=1)
def run(alias):
"""
### `bork run NAME`

Run the alias specified by NAME, as defined in pyproject.toml.
"""
api.run(alias)


Expand Down
3 changes: 3 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Bork API

::: bork.api
47 changes: 47 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Bork

::: bork.cli
options:
members: []
show_root_toc_entry: False

::: bork.cli.aliases
options:
show_source: False
show_root_toc_entry: False


::: bork.cli.build
options:
show_source: False
show_root_toc_entry: False


::: bork.cli.clean
options:
show_source: False
show_root_toc_entry: False


::: bork.cli.dependencies
options:
show_source: False
show_root_toc_entry: False


::: bork.cli.download
options:
show_source: False
show_root_toc_entry: False


::: bork.cli.release
options:
show_source: False
show_root_toc_entry: False


::: bork.cli.run
options:
show_source: False
show_root_toc_entry: False
16 changes: 16 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
site_name: bork
site_description: "Documentation for Bork, the build and release management tool for Python."
repo_url: https://github.com/duckinator/bork
edit_uri: blob/main/docs/

nav:
- Home: index.md
- API: api.md

plugins:
- search
- mkdocstrings

theme:
name: readthedocs
highlightjs: true
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ testing =
pytest-pylint==0.19.0
pytest-mypy==0.10.1

docs =
mkdocs==1.4.2
mkdocstrings[python]==0.21.2

[options.entry_points]
console_scripts =
bork = bork.cli:main