#include <tools/ccanlint/ccanlint.h>
#include <tools/doc_extract.h>
+#include <tools/tools.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
{
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))
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));
}
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");
}
"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;
}
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);