dig docs command

This commit is contained in:
2026-01-21 20:53:24 +11:00
parent b4fd43fb9b
commit d8cddfbbd4
3 changed files with 107 additions and 17 deletions

View File

@@ -61,27 +61,53 @@ def build(args):
with console.status("Packaging...", spinner="bouncingBall", spinner_style="green"):
build_dir = f"{os.path.basename(args.folder_path)}_build"
if os.path.isdir(build_dir):
shutil.rmtree(build_dir)
os.mkdir(build_dir)
if not os.path.isdir(build_dir):
os.mkdir(build_dir)
# generate a mineral.ini file
config_parser = configparser.ConfigParser()
config_parser["package"] = {
"description": "Your description here",
"version": "1.0.0",
"config_version": "1",
}
config_parser["dependencies"] = {}
# write it to our new mineral
with open(os.path.join(build_dir, "mineral.ini"), "w") as f:
config_parser.write(f)
# generate doc files
docs_folder = os.path.join(build_dir, "docs")
if not os.path.isdir(docs_folder):
os.mkdir(docs_folder)
with open(os.path.join(docs_folder, "my_function.md"), "w") as f:
f.write("# mylib_MyFunction\n")
f.write("Describe your function briefly.\n\n")
f.write("## Arguments\n")
f.write("- myArgument (double): describe your arguments in a list format like this.\n\n")
f.write("## Returns\n")
f.write("result (int): then explain what the function returns\n\n")
f.write("## Example\n")
f.write("```python\n")
f.write("# then show how you use the function in an example\n")
f.write("call !mylib_MyFunction 123.0 &result\n")
f.write("```\n")
f.write("`Using \"python\" as the syntax highlighting language seems to work well with Ground.`")
with open(os.path.join(build_dir, "SUMMARY.md"), "w") as f:
f.write("# mylib\n")
f.write("Introduce your module here!\n\nThis file will serve as an index page for all your docs.\n\n")
f.write("## Subtitle (use this for categories)\n")
f.write("- [mylib_MyFunction](docs/my_function.md)")
console.print("[:white_check_mark:] Generated a new package for you!")
shutil.move("main.so", os.path.join(build_dir, "main.so"))
# generate a mineral.ini file
config_parser = configparser.ConfigParser()
config_parser["package"] = {
"description": "Your description here",
"version": "1.0.0",
"config_version": "1"
}
config_parser["dependencies"] = {}
console.print("[:white_check_mark:] Put your library into your package!")
# write it to our new mineral
with open(os.path.join(build_dir, "mineral.ini"), "w") as f:
config_parser.write(f)
console.print("[:white_check_mark:] Packaged!")
console.print(f"\n[b cyan]note:[/] You will need to edit the [i]mineral.ini[/] file to make sure the version number and dependencies are correct, and also rename your \"{os.path.basename(build_dir)}\" folder to the name of your mineral.")
else:
check_sudo()
check_ground_libs_path()