示例#1
0
文件: docgen.c 项目: shlomif/ponyc
// 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);
}
示例#2
0
文件: docgen.c 项目: JamesLinus/ponyc
// 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);
}