Merge branch 'master' of https://github.com/Microsoft/TouchDevelop
This commit is contained in:
Коммит
a1e6aebe1b
|
@ -22,6 +22,11 @@ module TDev.AST.MdDocs {
|
|||
return "\n```" + this.finalize(true) + "\n```\n\n";
|
||||
}
|
||||
|
||||
public comment(s:string)
|
||||
{
|
||||
this.op("//").space().write(formatText(s).trim()).nl();
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
function formatText(s:string)
|
||||
|
@ -32,6 +37,7 @@ module TDev.AST.MdDocs {
|
|||
warnS += "WARN: " + m + "\n"
|
||||
}
|
||||
|
||||
s = s.replace(/\s+/g, " ").trim()
|
||||
s = s.replace(/^\{([\w\*]+)(:([^{}]*))?\}/g, (full, macro, dummy, arg) => {
|
||||
if (macro == "sig") {
|
||||
var m = arg.split(/->/);
|
||||
|
@ -48,10 +54,19 @@ module TDev.AST.MdDocs {
|
|||
warn("cannot find lib action: " + arg)
|
||||
return full;
|
||||
}
|
||||
} else if (macro == "fullsig" || macro == "decl") {
|
||||
} else if (macro == "decl") {
|
||||
var d = TDev.Script.things.filter(t => t.getName() == arg)[0]
|
||||
if (!d) {
|
||||
warn("no such decl: " + arg)
|
||||
return full;
|
||||
}
|
||||
else
|
||||
return mkSnippet([d])
|
||||
} else if (macro == "fullsig") {
|
||||
warn("unsupported macro: " + macro)
|
||||
return full;
|
||||
} else {
|
||||
warnS += "MACRO: " + macro
|
||||
return full;
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1734,6 +1734,19 @@ function ts(files:string[])
|
|||
console.log("out.ts and apis.json written")
|
||||
}
|
||||
|
||||
function mddocs(files:string[])
|
||||
{
|
||||
files.forEach(f => {
|
||||
var t = fs.readFileSync(f, "utf8")
|
||||
TDev.AST.reset();
|
||||
TDev.AST.loadScriptAsync((s) => TDev.Promise.as(s == "" ? t : null));
|
||||
var md = TDev.AST.MdDocs.toMD(TDev.Script)
|
||||
var mdF = f.replace(/\.td$/, "").replace(/$/, ".md")
|
||||
fs.writeFileSync(mdF, md)
|
||||
console.log("written", mdF)
|
||||
})
|
||||
}
|
||||
|
||||
function featureize(dirs:string[])
|
||||
{
|
||||
libroots = JSON.parse(fs.readFileSync("libroots.json", "utf-8"))
|
||||
|
@ -2069,6 +2082,8 @@ export function globalInit()
|
|||
compilerTest();
|
||||
} else if (process.argv[2] == "ts") {
|
||||
ts(process.argv.slice(3))
|
||||
} else if (process.argv[2] == "mddocs") {
|
||||
mddocs(process.argv.slice(3))
|
||||
} else {
|
||||
console.log("invalid usage")
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче