Skip to content

Commit 185d820

Browse files
committed
[libc][docs] Generate docs for signal.h & optimized docgen.py's is_implemented func. (#87835)
1 parent 2bc637b commit 185d820

File tree

3 files changed

+83
-4
lines changed

3 files changed

+83
-4
lines changed

libc/docs/signal.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
signal.h Functions
2+
==================
3+
4+
.. list-table::
5+
:widths: auto
6+
:align: center
7+
:header-rows: 1
8+
9+
* - Function
10+
- Implemented
11+
- Standard
12+
* - kill
13+
- |check|
14+
-
15+
* - raise
16+
- |check|
17+
- 7.14.2.1
18+
* - sigaction
19+
- |check|
20+
-
21+
* - sigaddset
22+
- |check|
23+
-
24+
* - sigaltstack
25+
- |check|
26+
-
27+
* - sigdelset
28+
- |check|
29+
-
30+
* - sigemptyset
31+
- |check|
32+
-
33+
* - sigfillset
34+
- |check|
35+
-
36+
* - signal
37+
- |check|
38+
- 7.14.1.1
39+
* - sigprocmask
40+
- |check|
41+
-

libc/utils/docgen/docgen.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,21 @@ def load_api(hname: str) -> Dict:
2323
# TODO: we may need to get more sophisticated for less generic implementations.
2424
# Does libc/src/{hname minus .h suffix}/{fname}.cpp exist?
2525
def is_implemented(hname: str, fname: str) -> bool:
26-
return Path(
26+
path = Path(
2727
Path(__file__).parent.parent.parent,
2828
"src",
29-
hname.rstrip(".h"),
30-
fname + ".cpp",
31-
).exists()
29+
hname.rstrip(".h")
30+
)
31+
source_file_name = fname + ".cpp"
32+
if path.joinpath(source_file_name).exists():
33+
return True
34+
35+
# Attempt to search in the subfolders with 1-depth.
36+
for sub_dir in path.iterdir():
37+
if (sub_dir.joinpath(source_file_name)).exists():
38+
return True
39+
40+
return False
3241

3342

3443
def print_functions(header: str, functions: Dict):

libc/utils/docgen/signal.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"macros": [
3+
"SIG_DFL",
4+
"SIG_ERR",
5+
"SIG_IGN",
6+
"SIGABRT",
7+
"SIGFPE",
8+
"SIGILL",
9+
"SIGINT",
10+
"SIGSEGV",
11+
"SIGTERM"
12+
],
13+
"functions": {
14+
"kill": null,
15+
"sigaction": null,
16+
"sigaddset": null,
17+
"sigaltstack": null,
18+
"sigdelset": null,
19+
"sigemptyset": null,
20+
"sigfillset": null,
21+
"sigprocmask": null,
22+
"signal": {
23+
"defined": "7.14.1.1"
24+
},
25+
"raise": {
26+
"defined": "7.14.2.1"
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)