-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39ccb3f
commit acc7f6c
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import std/[os,strformat,sugar,osproc] | ||
import std/private/globs | ||
|
||
iterator findNimSrcFiles*(dir: string): string = | ||
proc follow(a: PathEntry): bool = | ||
a.path.lastPathPart notin ["nimcache", "htmldocs"] | ||
for entry in walkDirRecFilter(dir, follow = follow): | ||
if entry.path.splitFile.ext == ".nim" and entry.kind == pcFile: | ||
yield entry.path | ||
|
||
proc genCodeImportAll*(dir: string): string = | ||
result = "{.warning[UnusedImport]: off.}\n" | ||
for a in findNimSrcFiles(dir): | ||
let s = "".dup(addQuoted(a)) | ||
result.add &"import {s}\n" | ||
|
||
proc genDocs(dir: string, nim = "", args: seq[string]) = | ||
let code = genCodeImportAll(dir) | ||
let extra = quoteShellCommand(args) | ||
let nim = if nim.len == 0: getCurrentCompilerExe() else: nim | ||
let ret = execCmdEx(fmt"{nim} doc -r --project --docroot --outdir:htmldocs {extra} -", input = code) | ||
if ret.exitCode != 0: | ||
doAssert false, ret.output & "\n" & code | ||
|
||
when isMainModule: | ||
let args = commandLineParams() | ||
doAssert args.len >= 1 | ||
let dir = args[0] | ||
genDocs(dir, nim="", args[1..^1]) |