"Fossies" - the Fresh Open Source Software Archive

Member "dmd-2.089.0/docs/gen_man.d" (2 Nov 2019, 3631 Bytes) of package /linux/misc/dmd-2.089.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) D source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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