On this page
CLI interface for selfdoc -- defines the command-line entry point, argument parsing via strictcli, and subcommand dispatch for all commands.
#selfdoc.cli
The cli module defines selfdoc's command-line interface using strictcli. It registers the top-level selfdoc app and all subcommands: init, build, serve, check, gen, gen-data, deploy, and quality, plus command groups for post, assembly, and baseline. Each command function parses flags, loads config via selfdoc.config, and delegates to the corresponding implementation module. The serve command starts an HTTP server with live-reload for local development.
Several commands that previously lived in selfdoc (post new, post list, post generate, post publish, and the assembly subcommands) have been migrated to the standalone selfblog CLI. Their registrations remain as stubs that emit a directed error message, so old invocations fail cleanly instead of producing an unknown-command error. Developers typically interact with this module indirectly by running selfdoc <command> on the command line; the run() function at the bottom is the entry point called by python -m selfdoc and the npm wrapper.
#selfdoc.cli
CLI interface for selfdoc -- defines the command-line entry point, argument parsing via strictcli, and subcommand dispatch for all commands.
#_fail
def _fail(exc)Print exc as a refusal and exit 1.
#_load_config_or_fail
def _load_config_or_fail(dir_path='.')Load the project config, or refuse cleanly.
Every command reads the config, and a present-but-unusable one is a user error at each of them. Loading through here is what keeps a command from ending on a ConfigError traceback because it forgot the handler that its neighbour remembered.
#_detect_source_entries
def _detect_source_entries(language)Detect source entries for a given language.
Returns a list of {"path": ..., "language": ...} dicts suitable for the source field in selfdoc.json.
#_detect_main_module
def _detect_main_module()Detect the main module name for the starter template.
#_cmd_init
def _cmd_init(ctx, base_url, author_name, author_url, auto_commit=True)Initialize selfdoc in the current project.
#_cmd_build
def _cmd_build(ctx, auto_commit=True, locale='', version='', drafts=False, target='')Build the documentation site.
#_cmd_serve
def _cmd_serve(ctx, port=8000, drafts=False)Serve the documentation site locally with SSE-based live reload.
#_cmd_deploy
def _cmd_deploy(ctx)Deploy the documentation site.
#_cmd_check
def _cmd_check(ctx, ignore='', format='text', auto_commit=True, version_override='')Check documentation coverage and consistency.
#_cmd_baseline_accept
def _cmd_baseline_accept(ctx, page, auto_commit=True)Accept reviewed staleness/drift for the named pages.
#_cmd_gen
def _cmd_gen(ctx, auto_commit=True, version_override='')Auto-generate documentation pages from project structure.
#_cmd_gen_data
def _cmd_gen_data(ctx, auto_commit=True)Generate data files by running sandboxed scripts.
#_cmd_spell_corpus
def _cmd_spell_corpus(ctx, root='', format='text', detail=True)Run the spelling engine across every sibling selfdoc project.
#run
def run()Parse arguments and dispatch to the appropriate subcommand.