fix(scripts): ignore declarations without a description (#122)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
@@ -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:
|
||||
|
||||
@@ -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 != "")
|
||||
]'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user