Permalink
Browse files

more tags for dman

  • Loading branch information...
1 parent f078971 commit 084951b76c18b0e7887965ae624f0da31d66be35 @WalterBright WalterBright committed Nov 11, 2012
Showing with 193 additions and 32 deletions.
  1. +81 −29 dman.d
  2. +112 −3 win32.mak
View
@@ -1,3 +1,4 @@
+
import std.stdio;
import std.getopt;
import std.algorithm;
@@ -8,12 +9,16 @@ import std.process;
int main(string[] args)
{
+ char dman = 'd';
+ if (find(args[0], "cman").length)
+ dman = 'c';
+
if (args.length < 2)
{
- writeln("dman: Look up D topics in the manual
+ writefln("%sman: Look up %s topics in the manual
Usage:
- dman [--man] topic
-");
+ %sman [--man] topic
+", dman, dman == 'c' ? 'C' : 'D', dman);
return 1;
}
@@ -24,52 +29,73 @@ Usage:
{ browse("http://www.digitalmars.com/ctg/dman.html");
return 0;
}
- else if (args.length != 2)
+ else if (args.length < 2)
{
- writeln("dman: no topic");
+ writefln("%sman: no topic", dman);
return 1;
}
auto topic = args[1];
+ foreach (a; args[2..$])
+ topic ~= " " ~ a;
- auto url = topic2url(topic);
+ auto url = topic2url(dman, topic);
if (url)
{
browse(url);
}
else
{
- writefln("dman: topic '%s' not found", topic);
+ writefln("%sman: topic '%s' not found", dman, topic);
return 1;
}
return 0;
}
-string topic2url(string topic)
+string topic2url(char dman, string topic)
{
/* Instead of hardwiring these, dman should read from a .json database pointed to
* by sc.ini or dmd.conf.
*/
string url;
- url = DmcCommands(topic);
- if (!url)
- url = Ddoc(topic);
- if (!url)
- url = CHeader(topic);
- if (!url)
- url = Clib(topic);
- if (!url)
- url = Misc(topic);
- if (!url)
- url = Phobos(topic);
- if (!url)
- // Try "I'm Feeling Lucky"
- url = "http://www.google.com/search?q=" ~
- std.uri.encode(topic) ~
- "&as_oq=site:dlang.org+site:digitalmars.com&btnI=I%27m+Feeling+Lucky";
+ if (dman == 'c')
+ {
+ url = DmcCommands(topic);
+ if (!url)
+ url = CHeader(topic);
+ if (!url)
+ url = Clib(topic);
+ if (!url)
+ url = Misc(topic);
+ if (!url)
+ // Try "I'm Feeling Lucky"
+ url = "http://www.google.com/search?q=" ~
+ "site:digitalmars.com " ~
+ std.uri.encode(topic) ~
+ "&btnI=I%27m+Feeling+Lucky";
+ }
+ else
+ {
+ url = DmcCommands(topic);
+ if (!url)
+ url = Ddoc(topic);
+ if (!url)
+ url = Misc(topic);
+ if (!url)
+ url = Phobos(topic);
+ if (!url)
+ url = CHeader(topic);
+ if (!url)
+ url = Clib(topic);
+ if (!url)
+ // Try "I'm Feeling Lucky"
+ url = "http://www.google.com/search?q=" ~
+ std.uri.encode(topic) ~
+ "&as_oq=site:d-programming-language.org+site:digitalmars.com&btnI=I%27m+Feeling+Lucky";
+ }
return url;
}
@@ -103,14 +129,14 @@ string Ddoc(string topic)
if (find(etags, topic).length)
{
- return "http://dlang.org/expression.html#" ~ topic;
+ return "http://www.d-programming-language.org/expression.html#" ~ topic;
}
static string[] stags = mixin (import("statement.tag"));
if (find(stags, topic).length)
{
- return "http://dlang.org/statement.html#" ~ topic;
+ return "http://www.d-programming-language.org/statement.html#" ~ topic;
}
return null;
}
@@ -853,8 +879,8 @@ string Misc(string topic)
string[string] misc =
[
"D1": "http://www.digitalmars.com/d/1.0/",
- "D2": "http://dlang.org/",
- "faq": "http://dlang.org/faq.html",
+ "D2": "http://www.d-programming-language.org/",
+ "faq": "http://d-programming-language.org/faq.html",
];
auto purl = topic in misc;
@@ -863,9 +889,35 @@ string Misc(string topic)
return null;
}
+string moduleTag(string modulename)
+{
+ return
+ "static string[] " ~ modulename ~ "_tags = mixin (import(\"std_" ~ modulename ~ ".tag\"));
+ if (find(" ~ modulename ~ "_tags, topic).length)
+ {
+ return \"http://www.d-programming-language.org/phobos/std_" ~ modulename ~ ".html#\" ~ topic;
+ }
+ ";
+}
+
string Phobos(string topic)
{
- string phobos = "http://dlang.org/phobos/";
+ mixin(moduleTag("algorithm"));
+ mixin(moduleTag("array"));
+ mixin(moduleTag("file"));
+ mixin(moduleTag("format"));
+ mixin(moduleTag("math"));
+ mixin(moduleTag("parallelism"));
+ mixin(moduleTag("path"));
+ mixin(moduleTag("random"));
+ mixin(moduleTag("range"));
+ mixin(moduleTag("regex"));
+ mixin(moduleTag("stdio"));
+ mixin(moduleTag("string"));
+ mixin(moduleTag("traits"));
+ mixin(moduleTag("typetuple"));
+
+ string phobos = "http://www.d-programming-language.org/phobos/";
if (find(topic, '.').length)
{
topic = replace(topic, regex("\\.", "g"), "_");
View
@@ -1,25 +1,134 @@
-DMD=\cbx\mars\dmd
DOC=\cbx\mars\doc
+PHOBOSDOC=\cbx\mars\doc\phobos
+# Where scp command copies to
+SCPDIR=..\backup
+
+##### Tools
+
+# D compiler
+DMD=dmd
+# C++ compiler
+CC=dmc
+# Make program
+MAKE=make
+# Librarian
+LIB=lib
+# Delete file(s)
+DEL=del
+# Make directory
+MD=mkdir
+# Remove directory
+RD=rmdir
+# File copy
+CP=cp
+# De-tabify
+DETAB=detab
+# Convert line endings to Unix
+TOLF=tolf
+# Zip
+ZIP=zip32
+# Copy to another directory
+SCP=$(CP)
+
+DFLAGS=-O -release
TARGETS=dman.exe findtags.exe
+MAKEFILES=win32.mak
+
+SRCS=dman.d findtags.d
+
TAGS= expression.tag \
- statement.tag
+ statement.tag \
+ std_algorithm.tag \
+ std_array.tag \
+ std_file.tag \
+ std_format.tag \
+ std_math.tag \
+ std_parallelism.tag \
+ std_path.tag \
+ std_random.tag \
+ std_range.tag \
+ std_regex.tag \
+ std_stdio.tag \
+ std_string.tag \
+ std_traits.tag \
+ std_typetuple.tag
targets : $(TARGETS)
expression.tag : findtags.exe $(DOC)\expression.html
+findtags $(DOC)\expression.html >expression.tag
+
statement.tag : findtags.exe $(DOC)\statement.html
+findtags $(DOC)\statement.html >statement.tag
+std_algorithm.tag : findtags.exe $(PHOBOSDOC)\std_algorithm.html
+ +findtags $(PHOBOSDOC)\std_algorithm.html >std_algorithm.tag
+
+std_array.tag : findtags.exe $(PHOBOSDOC)\std_array.html
+ +findtags $(PHOBOSDOC)\std_array.html >std_array.tag
+
+std_file.tag : findtags.exe $(PHOBOSDOC)\std_file.html
+ +findtags $(PHOBOSDOC)\std_file.html >std_file.tag
+
+std_format.tag : findtags.exe $(PHOBOSDOC)\std_format.html
+ +findtags $(PHOBOSDOC)\std_format.html >std_format.tag
+
+std_math.tag : findtags.exe $(PHOBOSDOC)\std_math.html
+ +findtags $(PHOBOSDOC)\std_math.html >std_math.tag
+
+std_parallelism.tag : findtags.exe $(PHOBOSDOC)\std_parallelism.html
+ +findtags $(PHOBOSDOC)\std_parallelism.html >std_parallelism.tag
+
+std_path.tag : findtags.exe $(PHOBOSDOC)\std_path.html
+ +findtags $(PHOBOSDOC)\std_path.html >std_path.tag
+
+std_random.tag : findtags.exe $(PHOBOSDOC)\std_random.html
+ +findtags $(PHOBOSDOC)\std_random.html >std_random.tag
+
+std_range.tag : findtags.exe $(PHOBOSDOC)\std_range.html
+ +findtags $(PHOBOSDOC)\std_range.html >std_range.tag
+
+std_regex.tag : findtags.exe $(PHOBOSDOC)\std_regex.html
+ +findtags $(PHOBOSDOC)\std_regex.html >std_regex.tag
+
+std_stdio.tag : findtags.exe $(PHOBOSDOC)\std_stdio.html
+ +findtags $(PHOBOSDOC)\std_stdio.html >std_stdio.tag
+
+std_string.tag : findtags.exe $(PHOBOSDOC)\std_string.html
+ +findtags $(PHOBOSDOC)\std_string.html >std_string.tag
+
+std_traits.tag : findtags.exe $(PHOBOSDOC)\std_traits.html
+ +findtags $(PHOBOSDOC)\std_traits.html >std_traits.tag
+
+std_typetuple.tag : findtags.exe $(PHOBOSDOC)\std_typetuple.html
+ +findtags $(PHOBOSDOC)\std_typetuple.html >std_typetuple.tag
+
+
findtags.exe : findtags.d
$(DMD) findtags.d
dman.exe : dman.d $(TAGS)
- $(DMD) dman.d -J.
+ $(DMD) $(DFLAGS) dman.d -J.
clean :
del $(TARGETS) $(TAGS)
+
+detab:
+ $(DETAB) $(SRCS)
+
+tolf:
+ $(TOLF) $(SRCS) $(MAKEFILES)
+
+zip: detab tolf $(MAKEFILES)
+ $(DEL) dman.zip
+ $(ZIP) dman $(MAKEFILES) $(SRCS) $(TAGS)
+
+scp: detab tolf $(MAKEFILES)
+ $(SCP) $(SRCS) $(MAKEFILES) $(SCPDIR)
+
+
+

0 comments on commit 084951b

Please sign in to comment.