-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a script that automatically update function indexing when u…
…sing the `FunctionOrder::ByIndex` option (#7) * chore: move auto index script to a script folder * docs: add documentation for the index script * feat: add help for the index script * chore: clippy fix
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
|
||
if len(sys.argv) != 2: | ||
print("""usage: rhai-autodocs-indexer.py <path-to-source-file> | ||
This script searches for any `# rhai-autodocs:index:` comment and | ||
automatically adds the index number following the order of the function | ||
in the source file. | ||
See the `FunctionOrder::ByIndex` option from the rhai-autodocs crate. | ||
""") | ||
exit(1) | ||
|
||
file = sys.argv[1] | ||
|
||
oldfile = open(file, 'r') | ||
newfile = open(f"{file}.autodocs", 'w') | ||
|
||
function_order = 1 | ||
for line in oldfile: | ||
newline = "" | ||
if "# rhai-autodocs:index:" in line: | ||
newline = f" /// # rhai-autodocs:index:{function_order}\n" | ||
function_order += 1 | ||
else: | ||
newline = line | ||
|
||
newfile.write(newline) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters