X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fhas_info_documentation.c;h=cdfb0e2c63f3e29c9856887b49badbb356287722;hp=8a506aba85253596975462dd1532038d30d6e79c;hb=6ceee26828dcb8bf1d607a8221f0d9f8261d448b;hpb=570c9c555f076e74f46141bb42b5d1d7ac89f632 diff --git a/tools/ccanlint/tests/has_info_documentation.c b/tools/ccanlint/tests/has_info_documentation.c index 8a506aba..cdfb0e2c 100644 --- a/tools/ccanlint/tests/has_info_documentation.c +++ b/tools/ccanlint/tests/has_info_documentation.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -18,14 +19,15 @@ struct info_docs { bool summary; bool description; - bool example; }; -static void *check_has_info_documentation(struct manifest *m) +static void *check_has_info_documentation(struct manifest *m, + bool keep, + unsigned int *timeleft) { struct list_head *infodocs = get_ccan_file_docs(m->info_file); struct doc_section *d; - struct info_docs id = { false, false, false }; + struct info_docs id = { false, false }; list_for_each(infodocs, d, list) { if (!streq(d->function, m->basename)) @@ -34,11 +36,9 @@ static void *check_has_info_documentation(struct manifest *m) id.summary = true; if (streq(d->type, "description")) id.description = true; - if (streq(d->type, "example")) - id.example = true; } - if (id.summary && id.description && id.example) + if (id.summary && id.description) return NULL; return talloc_memdup(m, &id, sizeof(id)); } @@ -81,7 +81,7 @@ static void create_info_template_doc(struct manifest *m, void *check_result) unlink_noerr("_info.new"); err(1, "Closing _info.new"); } - if (rename("_info.new", "_info") != 0) { + if (!move_file("_info.new", "_info")) { unlink_noerr("_info.new"); err(1, "Renaming _info.new to _info"); } @@ -106,11 +106,6 @@ static const char *describe_has_info_documentation(struct manifest *m, "The lines after the first summary line in the _info file\n" "documentation should describe the purpose and use of the\n" "overall package\n"); - if (!id->example) - reason = talloc_asprintf_append(reason, - "Your _info file has no module example.\n\n" - "There should be an Example: section of the _info documentation\n" - "which provides a concise toy program which uses your module\n"); return reason; } @@ -118,13 +113,16 @@ static unsigned int has_info_documentation_score(struct manifest *m, void *check_result) { struct info_docs *id = check_result; - return id->summary + id->description + id->example; + return (unsigned int)id->summary + id->description; } struct ccanlint has_info_documentation = { - .name = "Documentation in _info file", - .total_score = 3, + .key = "info-documentation", + .name = "Module has documentation in _info", + .total_score = 2, .score = has_info_documentation_score, .check = check_has_info_documentation, .describe = describe_has_info_documentation, }; + +REGISTER_TEST(has_info_documentation, NULL);