Files
ai-agent-book/chapter9/gaia-experience/AWorld/docs/outline.py
T
liqiang b119135836
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
2026-08-20 13:12:50 +00:00

82 lines
2.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# coding: utf-8
# Copyright (c) 2025 inclusionAI.
import os
from collections import OrderedDict
from typing import List
import yaml
docs = "docs"
black_keys = ["Index"]
black_values = ["index.md"]
file_priority = {"Quickstart": ["Install", "Agent Construction", "Workflow Construction",
"Multi-agent System Construction", "Environment"]
}
dir_order = ["Quickstart", "Tutorials"]
def scan_path(path: str) -> List[dict]:
items = scan(path)
res = []
for k, v in items.items():
# root path
if k in black_keys and v in black_values:
continue
# files in dir
final_map = OrderedDict()
for file in file_priority.get(k, []):
if file in v:
final_map[file] = v[file]
v.pop(file)
final_map.update(v)
res.append({k: dict(final_map)})
return res
def scan(path: str) -> dict:
items = {}
for name in sorted(os.listdir(path)):
p = os.path.join(path, name)
if name.startswith("."):
continue
if os.path.isdir(p):
children = scan(p)
if children:
items[name] = children
elif name.endswith(".md"):
words = os.path.splitext(name)[0].split('_')
key = ' '.join([w.capitalize() for w in words])
items[key] = os.path.relpath(p, docs).replace(os.sep, "/")
return items
if __name__ == '__main__':
outline = scan_path(docs)
cfg = {
"site_name": "AWorld Docs",
"site_url": "https://github.com/inclusionAI/AWorld",
"repo_url": "https://github.com/inclusionAI/AWorld",
"edit_uri": "tree/main/docs/",
"copyright": "\u00A9 Copyright 2025 inclusionAI AWorld Team.",
"extra_javascript": ["js/hide-home-edit.js"],
"theme": "readthedocs",
"nav": outline,
}
index_content = ["# Welcome to AWorlds Documentation!"]
# standard structure
for line in outline:
for k, v in line.items():
index_content.append(f"## {k}")
for s_k, s_v in v.items():
index_content.append(f"[{s_k}]({s_v})")
with open("index.md", 'w') as index_file:
index_file.write("\n\n".join(index_content))
with open('mkdocs.yml', 'w') as outfile:
yaml.safe_dump(cfg, outfile, sort_keys=False, allow_unicode=True)