// Document the packages in the given program static void doc_packages(docgen_t* docgen, ast_t* ast) { assert(ast != NULL); assert(ast_id(ast) == TK_PROGRAM); // The Main package appears first, other packages in alphabetical order ast_t* package_1 = NULL; ast_list_t packages = { NULL, NULL, NULL }; // Sort packages for(ast_t* p = ast_child(ast); p != NULL; p = ast_sibling(p)) { assert(ast_id(p) == TK_PACKAGE); if(strcmp(package_name(p), "$0") == 0) { assert(package_1 == NULL); package_1 = p; } else { const char* name = package_qualified_name(p); doc_list_add(&packages, p, name); } } // Process packages assert(package_1 != NULL); doc_package(docgen, package_1); for(ast_list_t* p = packages.next; p != NULL; p = p->next) doc_package(docgen, p->ast); }
// Document the packages in the given program static void doc_packages(docgen_t* docgen, ast_t* ast) { assert(ast != NULL); assert(ast_id(ast) == TK_PROGRAM); // The Main package appears first, other packages in alphabetical order ast_t* package_1 = ast_child(ast); assert(package_1 != NULL); ast_list_t packages = { NULL, NULL, NULL }; // Sort packages for(ast_t* p = ast_sibling(package_1); p != NULL; p = ast_sibling(p)) { assert(ast_id(p) == TK_PACKAGE); const char* name = package_qualified_name(p); doc_list_add(&packages, p, name, true); } // Process packages docgen->package_file = NULL; docgen->test_types = NULL; docgen->public_types = NULL; docgen->private_types = NULL; doc_package(docgen, package_1); for(ast_list_t* p = packages.next; p != NULL; p = p->next) doc_package(docgen, p->ast); }
// Add the given AST to the given list, using the name from the specified // child. // ASTs with hygenic names are ignored. // Leading underscores on names are ignored for sorting purposes. // When false the allow_public parameter causes ASTs with public names to be // ignored. allow_private does the same for private names. static void doc_list_add_named(ast_list_t* list, ast_t* ast, size_t id_index, bool allow_public, bool allow_private) { assert(list != NULL); assert(ast != NULL); const char* name = ast_name(ast_childidx(ast, id_index)); assert(name != NULL); if(name[0] == '$') // Ignore internally generated names return; if(name[0] == '_' && !allow_private) // Ignore private return; if(name[0] != '_' && !allow_public) // Ignore public return; if(name[0] == '_') // Ignore leading underscore for ordering name++; doc_list_add(list, ast, name); }