diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-12-06 22:37:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-06 22:37:16 +0800 |
commit | 9ba07edb2ec7fcdd628cfa7155c4853160ebd5c3 (patch) | |
tree | 4ae00008d9604bf997350f72f89cea60338c91b6 /tools/kochdocs.nim | |
parent | 4ca2dcb404aa1b92900e838790d5df554fc0cb9a (diff) | |
download | Nim-9ba07edb2ec7fcdd628cfa7155c4853160ebd5c3.tar.gz |
build the documentation of official packages (#20986)
* remove db stuffs * remove punycode * remove * fixes script * add cloner * patches * disable * patch * fixes external packages * disable two packages * preview documentation build * try again * fixes URL * fixes a bug * simplify * fixes documentaion * fixes * Apply suggestions from code review
Diffstat (limited to 'tools/kochdocs.nim')
-rw-r--r-- | tools/kochdocs.nim | 65 |
1 files changed, 48 insertions, 17 deletions
diff --git a/tools/kochdocs.nim b/tools/kochdocs.nim index 9d6e37cab..4fffc7533 100644 --- a/tools/kochdocs.nim +++ b/tools/kochdocs.nim @@ -2,6 +2,9 @@ import std/[os, strutils, osproc, sets, pathnorm, sequtils] +import officialpackages +export exec + when defined(nimPreviewSlimSystem): import std/assertions @@ -48,18 +51,6 @@ proc findNimImpl*(): tuple[path: string, ok: bool] = proc findNim*(): string = findNimImpl().path -proc exec*(cmd: string, errorcode: int = QuitFailure, additionalPath = "") = - let prevPath = getEnv("PATH") - if additionalPath.len > 0: - var absolute = additionalPath - if not absolute.isAbsolute: - absolute = getCurrentDir() / absolute - echo("Adding to $PATH: ", absolute) - putEnv("PATH", (if prevPath.len > 0: prevPath & PathSep else: "") & absolute) - echo(cmd) - if execShellCmd(cmd) != 0: quit("FAILURE", errorcode) - putEnv("PATH", prevPath) - template inFold*(desc, body) = if existsEnv("GITHUB_ACTIONS"): echo "::group::" & desc @@ -131,11 +122,7 @@ mm.md """.splitWhitespace().mapIt("doc" / it) withoutIndex = """ -lib/wrappers/mysql.nim -lib/wrappers/sqlite3.nim -lib/wrappers/postgres.nim lib/wrappers/tinyc.nim -lib/wrappers/odbcsql.nim lib/wrappers/pcre.nim lib/wrappers/openssl.nim lib/posix/posix.nim @@ -165,6 +152,35 @@ lib/posix/posix_openbsd_amd64.nim lib/posix/posix_haiku.nim """.splitWhitespace() + officialPackagesList = """ +pkgs/asyncftpclient/src/asyncftpclient.nim +pkgs/smtp/src/smtp.nim +pkgs/punycode/src/punycode.nim +pkgs/db_connector/src/db_connector/db_common.nim +pkgs/db_connector/src/db_connector/db_mysql.nim +pkgs/db_connector/src/db_connector/db_odbc.nim +pkgs/db_connector/src/db_connector/db_postgres.nim +pkgs/db_connector/src/db_connector/db_sqlite.nim +""".splitWhitespace() + + officialPackagesListWithoutIndex = """ +pkgs/db_connector/src/db_connector/mysql.nim +pkgs/db_connector/src/db_connector/sqlite3.nim +pkgs/db_connector/src/db_connector/postgres.nim +pkgs/db_connector/src/db_connector/odbcsql.nim +pkgs/db_connector/src/db_connector/private/dbutils.nim +""".splitWhitespace() + +proc findName(name: string): string = + doAssert name[0..4] == "pkgs/" + var i = 5 + while i < name.len: + if name[i] != '/': + inc i + result.add name[i] + else: + break + when (NimMajor, NimMinor) < (1, 1) or not declared(isRelativeTo): proc isRelativeTo(path, base: string): bool = let path = path.normalizedPath @@ -248,7 +264,8 @@ proc buildDoc(nimArgs, destPath: string) = # call nim for the documentation: let rst2html = getMd2html() var - commands = newSeq[string](rst2html.len + len(doc) + withoutIndex.len) + commands = newSeq[string](rst2html.len + len(doc) + withoutIndex.len + + officialPackagesList.len + officialPackagesListWithoutIndex.len) i = 0 let nim = findNim().quoteShell() for d in items(rst2html): @@ -269,6 +286,19 @@ proc buildDoc(nimArgs, destPath: string) = destPath / changeFileExt(splitFile(d).name, "html"), d] i.inc + + for d in items(officialPackagesList): + var nimArgs2 = nimArgs + if d.isRelativeTo("compiler"): doAssert false + commands[i] = nim & " doc $# --outdir:$# --index:on $#" % + [nimArgs2, destPath, d] + i.inc + for d in items(officialPackagesListWithoutIndex): + commands[i] = nim & " doc $# -o:$# $#" % + [nimArgs, + destPath / changeFileExt(splitFile(d).name, "html"), d] + i.inc + mexec(commands) exec(nim & " buildIndex -o:$1/theindex.html $1" % [destPath]) # caveat: this works so long it's called before `buildDocPackages` which @@ -318,6 +348,7 @@ proc buildJS(): string = proc buildDocsDir*(args: string, dir: string) = let args = nimArgs & " " & args let docHackJsSource = buildJS() + gitClonePackages(@["asyncftpclient", "punycode", "smtp", "db_connector"]) createDir(dir) buildDocSamples(args, dir) buildDoc(args, dir) # bottleneck |