MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / get_doc_entries

Function get_doc_entries

scripts/generate_docs_index.py:157–191  ·  view source on GitHub ↗

Read all .zh.md files in a data directory and extract metadata.

(data_dir: Path, section_key: str)

Source from the content-addressed store, hash-verified

155
156
157def get_doc_entries(data_dir: Path, section_key: str) -> List[dict]:
158 """Read all .zh.md files in a data directory and extract metadata."""
159 entries = []
160 if not data_dir.exists():
161 return entries
162
163 for md_file in sorted(data_dir.glob("*.zh.md")):
164 fm = read_front_matter(md_file)
165 if not fm:
166 continue
167
168 title_zh = ""
169 title_val = fm.get("title", {})
170 if isinstance(title_val, dict):
171 title_zh = title_val.get("zh", "")
172 elif isinstance(title_val, str):
173 title_zh = title_val
174
175 if not title_zh:
176 title_zh = md_file.stem.replace("-", " ").replace(".zh", "")
177
178 entries.append({
179 "slug": md_file.stem.replace(".zh", ""),
180 "title_zh": title_zh,
181 "doc_number": fm.get("document_number", ""),
182 "effective_date": fm.get("effective_date", ""),
183 "published_date": fm.get("published_date", ""),
184 "status": fm.get("status", "active"),
185 "source_url": fm.get("source_url", ""),
186 "regulation": fm.get("regulation", ""),
187 "category": fm.get("category", section_key),
188 "file": md_file,
189 })
190
191 return entries
192
193
194def group_nmpa_guidance(entries: List[dict]) -> Dict[str, List[dict]]:

Callers 1

mainFunction · 0.85

Calls 2

read_front_matterFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected