[libc-commits] [libc] [libc][docs] adds macro handling, POSIX status, and validation to docgen (PR #89421)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Mon Apr 22 12:57:44 PDT 2024
================
@@ -9,61 +9,160 @@
# ==-------------------------------------------------------------------------==#
from argparse import ArgumentParser, Namespace
from pathlib import Path
-from typing import Dict
+from typing import Dict, Generator
import sys
import json
-def load_api(hname: str) -> Dict:
- p = Path(__file__).parent / Path(hname).with_suffix(".json")
- api = p.read_text(encoding="utf-8")
- return json.loads(api)
+class DocgenAPIFormatError(Exception):
+ """Raised on fatal formatting errors with a description of a formatting error"""
-# TODO: we may need to get more sophisticated for less generic implementations.
-# Does libc/src/{hname minus .h suffix}/{fname}.cpp exist?
-def is_implemented(hname: str, fname: str) -> bool:
- path = Path(
- Path(__file__).parent.parent.parent,
- "src",
- hname.rstrip(".h")
- )
+class Header:
+ """
+ Maintains implementation information about a standard header file:
+ * where does its implementation dir live
+ * where is its macros file
+ * where is its docgen json file
- if not path.exists():
- raise FileNotFoundError(f"implementation dir does not exist: {path}")
+ By convention, the macro-only part of a header file is in a header-specific
+ file somewhere in the directory tree with root at
+ ``$LLVM_PROJECT_ROOT/libc/include/llvm-libc-macros``. Docgen expects that
+ if a macro is implemented, that it appears in a string
+ ``#define MACRO_NAME`` in some ``*-macros.h`` file in the directory tree..
----------------
nickdesaulniers wrote:
```suggestion
``#define MACRO_NAME`` in some ``*-macros.h`` file in the directory tree.
```
https://github.com/llvm/llvm-project/pull/89421
More information about the libc-commits
mailing list