summary refs log tree commit diff stats
path: root/koch.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-09-13 18:47:53 +0200
committerAraq <rumpf_a@web.de>2018-09-13 18:47:53 +0200
commitb1b58b88cc4e233766429c42757b053db9a2761a (patch)
tree60d099449ea310b427a2cfc0ebc5c56444c781e2 /koch.nim
parente934ad61eb8265b7b5d3e6c385e87c5e8e95018d (diff)
downloadNim-b1b58b88cc4e233766429c42757b053db9a2761a.tar.gz
integrate 'koch web' features into koch; deprecate 'nimweb' tool
Diffstat (limited to 'koch.nim')
-rw-r--r--koch.nim86
1 files changed, 20 insertions, 66 deletions
diff --git a/koch.nim b/koch.nim
index 92b3d5934..66b64b020 100644
--- a/koch.nim
+++ b/koch.nim
@@ -23,6 +23,8 @@ when defined(i386) and defined(windows) and defined(vcc):
 import
   os, strutils, parseopt, osproc, streams
 
+import tools / kochdocs
+
 const VersionAsString = system.NimVersion
 
 const
@@ -49,9 +51,7 @@ Boot options:
                            (not needed on Windows)
 
 Commands for core developers:
-  web [options]            generates the website and the full documentation
-                           (see `nimweb.nim` for cmd line options)
-  website [options]        generates only the website
+  docs [options]           generates the full documentation
   csource -d:release       builds the C sources for installation
   pdf                      builds the PDF documentation
   zip                      builds the installation zip package
@@ -67,13 +67,6 @@ Web options:
                            build the official docs, use UA-48159761-1
 """
 
-const gaCode = " --googleAnalytics:UA-48159761-1"
-
-proc exe(f: string): string =
-  result = addFileExt(f, ExeExt)
-  when defined(windows):
-    result = result.replace('/','\\')
-
 template withDir(dir, body) =
   let old = getCurrentDir()
   try:
@@ -82,43 +75,6 @@ template withDir(dir, body) =
   finally:
     setCurrentdir(old)
 
-proc findNim(): string =
-  var nim = "nim".exe
-  result = "bin" / nim
-  if existsFile(result): return
-  for dir in split(getEnv("PATH"), PathSep):
-    if existsFile(dir / nim): return dir / nim
-  # assume there is a symlink to the exe or something:
-  return nim
-
-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)
-
-proc nimexec(cmd: string) =
-  exec findNim() & " " & cmd
-
-proc execCleanPath(cmd: string,
-                   additionalPath = ""; errorcode: int = QuitFailure) =
-  # simulate a poor man's virtual environment
-  let prevPath = getEnv("PATH")
-  when defined(windows):
-    let CleanPath = r"$1\system32;$1;$1\System32\Wbem" % getEnv"SYSTEMROOT"
-  else:
-    const CleanPath = r"/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin"
-  putEnv("PATH", CleanPath & PathSep & additionalPath)
-  echo(cmd)
-  if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
-  putEnv("PATH", prevPath)
-
 proc testUnixInstall() =
   let oldCurrentDir = getCurrentDir()
   try:
@@ -136,7 +92,7 @@ proc testUnixInstall() =
       execCleanPath("./bin/nim c koch.nim")
       execCleanPath("./koch boot -d:release", destDir / "bin")
       # check the docs build:
-      execCleanPath("./koch web", destDir / "bin")
+      execCleanPath("./koch docs", destDir / "bin")
       # check nimble builds:
       execCleanPath("./koch tools")
       # check the tests work:
@@ -295,18 +251,19 @@ proc install(args: string) =
   geninstall()
   exec("sh ./install.sh $#" % args)
 
-proc web(args: string) =
-  nimexec("js tools/dochack/dochack.nim")
-  nimexec("cc -r tools/nimweb.nim $# web/website.ini --putenv:nimversion=$#" %
-       [args, VersionAsString])
+when false:
+  proc web(args: string) =
+    nimexec("js tools/dochack/dochack.nim")
+    nimexec("cc -r tools/nimweb.nim $# web/website.ini --putenv:nimversion=$#" %
+        [args, VersionAsString])
 
-proc website(args: string) =
-  nimexec("cc -r tools/nimweb.nim $# --website web/website.ini --putenv:nimversion=$#" %
-       [args, VersionAsString])
+  proc website(args: string) =
+    nimexec("cc -r tools/nimweb.nim $# --website web/website.ini --putenv:nimversion=$#" %
+        [args, VersionAsString])
 
-proc pdf(args="") =
-  exec("$# cc -r tools/nimweb.nim $# --pdf web/website.ini --putenv:nimversion=$#" %
-       [findNim(), args, VersionAsString], additionalPATH=findNim().splitFile.dir)
+  proc pdf(args="") =
+    exec("$# cc -r tools/nimweb.nim $# --pdf web/website.ini --putenv:nimversion=$#" %
+        [findNim(), args, VersionAsString], additionalPATH=findNim().splitFile.dir)
 
 # -------------- boot ---------------------------------------------------------
 
@@ -429,7 +386,7 @@ proc winRelease*() =
   # anymore!
   # Build -docs file:
   when true:
-    web(gaCode)
+    buildDocs(gaCode)
     withDir "web/upload/" & VersionAsString:
       exec "7z a -tzip docs-$#.zip *.html" % VersionAsString
     overwriteFile "web/upload/$1/docs-$1.zip" % VersionAsString,
@@ -553,14 +510,11 @@ when isMainModule:
     case normalize(op.key)
     of "boot": boot(op.cmdLineRest)
     of "clean": clean(op.cmdLineRest)
-    of "web": web(op.cmdLineRest)
-    of "doc", "docs": web("--onlyDocs " & op.cmdLineRest)
-    of "json2": web("--json2 " & op.cmdLineRest)
-    of "website": website(op.cmdLineRest & gaCode)
-    of "web0":
+    of "doc", "docs": buildDocs(op.cmdLineRest)
+    of "doc0", "docs0":
       # undocumented command for Araq-the-merciful:
-      web(op.cmdLineRest & gaCode)
-    of "pdf": pdf()
+      buildDocs(op.cmdLineRest & gaCode)
+    of "pdf": buildPdfDoc(op.cmdLineRest, "doc/pdf")
     of "csource", "csources": csource(op.cmdLineRest)
     of "zip": zip(op.cmdLineRest)
     of "xz": xz(op.cmdLineRest)