csi_images.make_docs
Generates documentation for the current package. Run with make_docs
after
installing this package in a virtual environment.
Will generate documentation for every top-level folder except "resources".
Must live in the package_name module so that the alias can be installed.
1#!/usr/bin/env python 2 3""" 4Generates documentation for the current package. Run with `make_docs` after 5installing this package in a virtual environment. 6Will generate documentation for every top-level folder except "resources". 7Must live in the package_name module so that the alias can be installed. 8""" 9 10import os 11import argparse 12import subprocess 13 14script = """ 15source "%s/bin/activate" && 16pip install pdoc -q && 17pdoc -t docs/theme -o docs csi_images examples tests && 18echo "Successfully generated documentation at $(pwd)/docs." 19""" 20 21 22def argument_parser() -> argparse.Namespace: 23 parser = argparse.ArgumentParser( 24 description="Generate documentation for the current package." 25 ) 26 parser.add_argument( 27 "--venv", 28 help="The path to the virtual environment where pdoc is installed. " 29 "Relative paths are relative to the repository root.", 30 type=str, 31 default=".venv", 32 ) 33 return parser.parse_args() 34 35 36def main(): 37 args = argument_parser() 38 repository_path = os.path.dirname(os.path.dirname(__file__)) 39 # Check if args.venv is absolute or relative 40 if not os.path.isabs(args.venv): 41 args.venv = os.path.join(repository_path, args.venv) 42 if not os.path.isdir(args.venv): 43 raise FileNotFoundError(f"Virtual environment not found at {args.venv}.") 44 subprocess.run( 45 script % args.venv, shell=True, executable="/bin/bash", cwd=repository_path 46 ) 47 48 49if __name__ == "__main__": 50 main()
script =
'\nsource "%s/bin/activate" &&\npip install pdoc -q &&\npdoc -t docs/theme -o docs csi_images examples tests &&\necho "Successfully generated documentation at $(pwd)/docs."\n'
def
argument_parser() -> argparse.Namespace:
23def argument_parser() -> argparse.Namespace: 24 parser = argparse.ArgumentParser( 25 description="Generate documentation for the current package." 26 ) 27 parser.add_argument( 28 "--venv", 29 help="The path to the virtual environment where pdoc is installed. " 30 "Relative paths are relative to the repository root.", 31 type=str, 32 default=".venv", 33 ) 34 return parser.parse_args()
def
main():
37def main(): 38 args = argument_parser() 39 repository_path = os.path.dirname(os.path.dirname(__file__)) 40 # Check if args.venv is absolute or relative 41 if not os.path.isabs(args.venv): 42 args.venv = os.path.join(repository_path, args.venv) 43 if not os.path.isdir(args.venv): 44 raise FileNotFoundError(f"Virtual environment not found at {args.venv}.") 45 subprocess.run( 46 script % args.venv, shell=True, executable="/bin/bash", cwd=repository_path 47 )