forked from dlang/dmd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_man.d
More file actions
133 lines (117 loc) · 3.13 KB
/
gen_man.d
File metadata and controls
133 lines (117 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env rdmd
/**
Generate the DMD man page automatically.
Copyright: D Language Foundation 2017.
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
*/
const header =
`.TH DMD 1 "%s" "The D Language Foundation" "The D Language Foundation"
.SH NAME
dmd \- Digital Mars D2.x Compiler
.SH SYNOPSIS
.B dmd \fIfiles\fR ... [ \fI-switch\fR ... ]
.SH DESCRIPTION
.B dmd
Compiles source code written in the D programming language.
.SH OPTIONS
.IP "file, file.d, file.htm, file.html"
D source files to compile
.IP file.di
D interface files
.IP file.o
Object files to link in
.IP file.a
Library files to link in
.IP @cmdfile
A file to read more command-line arguments from,
which may contain # single-line comments`;
const footer =
`.SH LINKING
Linking is done directly by the
.B dmd
compiler after a successful compile. To prevent
.B dmd
from running the linker, use the
.B -c
switch.
.PP
The actual linking is done by running \fBgcc\fR.
This ensures compatibility with modules compiled with
\fBgcc\fR.
.SH FILES
.TP
.I /etc/dmd.conf
System wide \fBdmd\fR config file. See
.BR dmd.conf(5)
for details.
.SH ENVIRONMENT
The D compiler dmd uses the following environment
variables:
.IP DFLAGS 10
The value of
.B DFLAGS
is treated as if it were appended on the command line to
\fBdmd\fR.
.SH AUTHOR
Copyright (c) 1999-%s by The D Language Foundation written by Walter Bright
.SH "ONLINE DOCUMENTATION"
.UR https://dlang.org/dmd.html
https://dlang.org/dmd.html
.UE
.SH "SEE ALSO"
.BR dmd.conf (5)
.BR rdmd (1)
.BR dumpobj (1)
.BR obj2asm (1)
.BR gcc (1)`;
string bold(string w)
{
return `\fI` ~ w ~ `\fR`;
}
// capitalize the first letter
auto capitalize(string w)
{
import std.range, std.uni;
return w.take(1).asUpperCase.chain(w.dropOne);
}
void main()
{
import std.algorithm, std.array, std.conv, std.datetime, std.range, std.stdio, std.uni;
import std.process : environment;
import dmd.cli;
auto now = Clock.currTime;
auto diffable = environment.get("DIFFABLE", "0");
if (diffable == "1")
now = SysTime(DateTime(2018, 1, 1));
writefln(header, now.toISOExtString.take(10));
foreach (option; Usage.options)
{
if (option.os.isCurrentTargetOS)
{
import std.regex : regex, replaceAll;
string flag = option.flag;
string helpText = option.helpText;
// match <foo> or <foo.bar> in flag
enum fr = regex(r"<(\w+?\.?\w*?)>");
alias fcb = caps => caps[1].bold;
flag = flag.replaceAll!fcb(fr);
// replace any <foo> in helpText
alias hcb = hc => hc[1].bold;
helpText = helpText.replaceAll!hcb(fr);
writefln(".IP -%s", flag);
// Capitalize the first letter
writeln(helpText.capitalize);
}
}
writeln(`.SH TRANSITIONS
Language changes listed by \fB-transition=id\fR:`);
foreach (transition; Usage.transitions)
{
if (!transition.documented)
continue;
string additionalOptions;
writefln(".IP %s", transition.name.bold);
writeln(transition.helpText.capitalize);
}
writefln(footer, now.year);
}