Skip to content

Commit

Permalink
fix(scripts): ignore declarations without a description (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Nov 3, 2024
1 parent 2cac7d9 commit afbd03f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions scripts/build-declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ function main() {
const isTool = path.dirname(scriptfile) == "tools";
const contents = fs.readFileSync(process.argv[2], "utf8");
const functions = extractFunctions(contents, isTool);
let declarations = functions.map(({ funcName, jsdoc }) => {
let declarations = [];
for (const { funcName, jsdoc } of functions) {
const { description, params } = parseJsDoc(jsdoc, funcName);
if (!description) continue;
const declaration = buildDeclaration(funcName, description, params);
return declaration;
});
declarations.push(declaration);
}
if (isTool) {
const name = getBasename(scriptfile);
if (declarations.length > 0) {
Expand Down
6 changes: 4 additions & 2 deletions scripts/build-declarations.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def main(is_tool=True):
for function in functions:
func_name, docstring, func_args = function
description, params = parse_docstring(docstring)
if not description:
continue
declarations.append(
build_declaration(func_name, description, params, func_args)
)
Expand All @@ -42,10 +44,10 @@ def extract_functions(contents: str, is_tool: bool):
if not isinstance(node, ast.FunctionDef):
continue
func_name = node.name
if func_name.startswith("_"):
continue
if is_tool and func_name != TOOL_ENTRY_FUNC:
continue
if func_name.startswith("_"):
continue
docstring = ast.get_docstring(node) or ""
func_args = OrderedDict()
for arg in node.args.args:
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-declarations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ build_declarations() {
parameters: parse_parameter([.flag_options[] | select(.id != "help" and .id != "version")])
};
[
.[] | parse_declaration | select(.name | startswith("_") | not)
.[] | parse_declaration | select(.name | startswith("_") | not) | select(.description != "")
]'
}

Expand Down

0 comments on commit afbd03f

Please sign in to comment.