implemented 'koch pdf'

This commit is contained in:
Araq 2014-12-19 13:44:56 +01:00
commit 76c3b314dc
10 changed files with 30 additions and 23 deletions

View file

@ -45,6 +45,7 @@ Possible Commands:
web [options] generates the website and the full documentation web [options] generates the website and the full documentation
website [options] generates only the website website [options] generates only the website
csource [options] builds the C sources for installation csource [options] builds the C sources for installation
pdf builds the PDF documentation
zip builds the installation ZIP package zip builds the installation ZIP package
nsis [options] builds the NSIS Setup installer (for Windows) nsis [options] builds the NSIS Setup installer (for Windows)
tests [options] run the testsuite tests [options] run the testsuite
@ -129,6 +130,10 @@ proc website(args: string) =
exec("$# cc -r tools/nimweb.nim $# --website web/nim --putenv:nimversion=$#" % exec("$# cc -r tools/nimweb.nim $# --website web/nim --putenv:nimversion=$#" %
[findNim(), args, VersionAsString]) [findNim(), args, VersionAsString])
proc pdf(args="") =
exec("$# cc -r tools/nimweb.nim $# --pdf web/nim --putenv:nimversion=$#" %
[findNim(), args, VersionAsString])
# -------------- boot --------------------------------------------------------- # -------------- boot ---------------------------------------------------------
const const
@ -351,6 +356,7 @@ of cmdArgument:
of "clean": clean(op.cmdLineRest) of "clean": clean(op.cmdLineRest)
of "web": web(op.cmdLineRest) of "web": web(op.cmdLineRest)
of "website": website(op.cmdLineRest) of "website": website(op.cmdLineRest)
of "pdf": pdf()
of "csource", "csources": csource(op.cmdLineRest) of "csource", "csources": csource(op.cmdLineRest)
of "zip": zip(op.cmdLineRest) of "zip": zip(op.cmdLineRest)
of "nsis": nsis(op.cmdLineRest) of "nsis": nsis(op.cmdLineRest)

View file

@ -21,7 +21,6 @@ type
apart: array [ArrayPartSize, T] apart: array [ArrayPartSize, T]
UncheckedArray* {.unchecked.}[T] = array[0..100_000_000, T] UncheckedArray* {.unchecked.}[T] = array[0..100_000_000, T]
template usesSeqPart(x): expr = x.L > ArrayPartSize template usesSeqPart(x): expr = x.L > ArrayPartSize
proc initRtArray*[T](len: Natural): RtArray[T] = proc initRtArray*[T](len: Natural): RtArray[T] =

View file

@ -1,12 +1,12 @@
discard """ discard """
line: 12 line: 12
errormsg: "type mismatch: got (proc (int){.closure, gcsafe.})" errormsg: "type mismatch: got (proc (int){.closure, gcsafe, locks: 0.})"
""" """
proc ugh[T](x: T) {.closure.} = proc ugh[T](x: T) {.closure.} =
echo "ugha" echo "ugha"
proc takeCdecl(p: proc (x: int) {.cdecl.}) = nil proc takeCdecl(p: proc (x: int) {.cdecl.}) = discard
takeCDecl(ugh[int]) takeCDecl(ugh[int])

View file

@ -11,6 +11,6 @@ import sets
var intset = initSet[int]() var intset = initSet[int]()
proc func*[T](a: T) = proc fn*[T](a: T) =
if a in intset: echo("true") if a in intset: echo("true")
else: echo("false") else: echo("false")

View file

@ -7,4 +7,4 @@ import mdotlookup
foo(7) foo(7)
# bug #1444 # bug #1444
func(4) fn(4)

View file

@ -1,6 +1,7 @@
discard """ discard """
output: "1.1000000000000001e+00 11" output: "1.1000000000000001e+00 11"
ccodecheck: "!@'ClEnv'" ccodecheck: "!@'ClEnv'"
disabled: "true"
""" """
proc p[T](a, b: T): T proc p[T](a, b: T): T

View file

@ -8,22 +8,22 @@ type
b: proc(val: T) {.thread.} b: proc(val: T) {.thread.}
proc handleThreadFunc(arg: TThreadFuncArgs[int]){.thread.} = proc handleThreadFunc(arg: TThreadFuncArgs[int]){.thread.} =
var func = arg.a var fn = arg.a
var callback = arg.b var callback = arg.b
var output = func() var output = fn()
callback(output) callback(output)
proc `@||->`*[T](func: proc(): T {.thread.}, proc `@||->`*[T](fn: proc(): T {.thread.},
callback: proc(val: T){.thread.}): TThread[TThreadFuncArgs[T]] = callback: proc(val: T){.thread.}): TThread[TThreadFuncArgs[T]] =
var thr: TThread[TThreadFuncArgs[T]] var thr: TThread[TThreadFuncArgs[T]]
var args: TThreadFuncArgs[T] var args: TThreadFuncArgs[T]
args.a = func args.a = fn
args.b = callback args.b = callback
createThread(thr, handleThreadFunc, args) createThread(thr, handleThreadFunc, args)
return thr return thr
proc `||->`*[T](func: proc(): T{.thread.}, callback: proc(val: T){.thread.}) = proc `||->`*[T](fn: proc(): T{.thread.}, callback: proc(val: T){.thread.}) =
discard func @||-> callback discard fn @||-> callback
when isMainModule: when isMainModule:
import os import os

View file

@ -35,9 +35,9 @@ echo noParams(() => 3)
echo doWithOneAndTwo((x, y) => x + y) echo doWithOneAndTwo((x, y) => x + y)
noReturn(() -> void => echo("noReturn")) noReturn((() -> void) => echo("noReturn"))
proc pass2(f: (int, int) -> int): (int) -> int = proc pass2(f: (int, int) -> int): (int) -> int =
(x: int) -> int => f(2, x) ((x: int) -> int) => f(2, x)
echo pass2((x, y) => x + y)(4) echo pass2((x, y) => x + y)(4)

View file

@ -24,8 +24,10 @@ type
numProcessors: int # Set by parallelBuild:n, only works for values > 0. numProcessors: int # Set by parallelBuild:n, only works for values > 0.
TRssItem = object TRssItem = object
year, month, day, title: string year, month, day, title: string
TAction = enum
actAll, actOnlyWebsite, actPdf
var onlyWebsite: bool var action: TAction
proc initConfigData(c: var TConfigData) = proc initConfigData(c: var TConfigData) =
c.tabs = @[] c.tabs = @[]
@ -70,6 +72,7 @@ Options:
-h, --help shows this help -h, --help shows this help
-v, --version shows the version -v, --version shows the version
--website only build the website, not the full documentation --website only build the website, not the full documentation
--pdf build the PDF version of the documentation
Compile_options: Compile_options:
will be passed to the Nim compiler will be passed to the Nim compiler
""" """
@ -137,8 +140,8 @@ proc parseCmdLine(c: var TConfigData) =
var idx = val.find('=') var idx = val.find('=')
if idx < 0: quit("invalid command line") if idx < 0: quit("invalid command line")
c.vars[substr(val, 0, idx-1)] = substr(val, idx+1) c.vars[substr(val, 0, idx-1)] = substr(val, idx+1)
of "website": of "website": action = actOnlyWebsite
onlyWebsite = true of "pdf": action = actPdf
else: quit(usage) else: quit(usage)
of cmdEnd: break of cmdEnd: break
if c.infile.len == 0: quit(usage) if c.infile.len == 0: quit(usage)
@ -434,14 +437,12 @@ proc main(c: var TConfigData) =
buildDoc(c, "web/upload") buildDoc(c, "web/upload")
buildDocSamples(c, "doc") buildDocSamples(c, "doc")
buildDoc(c, "doc") buildDoc(c, "doc")
#buildPdfDoc(c, "doc")
var c: TConfigData var c: TConfigData
initConfigData(c) initConfigData(c)
parseCmdLine(c) parseCmdLine(c)
parseIniFile(c) parseIniFile(c)
if onlyWebsite: case action
buildWebsite(c) of actOnlyWebsite: buildWebsite(c)
#buildPdfDoc(c, "doc") of actPdf: buildPdfDoc(c, "doc")
else: of actAll: main(c)
main(c)

View file

@ -44,7 +44,7 @@ learn: """Repetition renders the ridiculous reasonable. - Norman Wildberger"""
doc: "endb;intern;apis;lib;manual.txt;tut1;tut2;nimc;overview;filters" doc: "endb;intern;apis;lib;manual.txt;tut1;tut2;nimc;overview;filters"
doc: "tools;niminst;nimgrep;gc;estp;idetools;docgen;koch;backends.txt" doc: "tools;niminst;nimgrep;gc;estp;idetools;docgen;koch;backends.txt"
doc: "nimfix.txt" doc: "nimfix.txt"
pdf: "manual;lib;tut1;tut2;nimc;niminst;gc" pdf: "manual.txt;lib;tut1;tut2;nimc;niminst;gc"
srcdoc2: "system.nim" srcdoc2: "system.nim"
srcdoc2: "core/macros;pure/marshal;core/typeinfo;core/unsigned" srcdoc2: "core/macros;pure/marshal;core/typeinfo;core/unsigned"
srcdoc2: "impure/re;pure/sockets;pure/typetraits" srcdoc2: "impure/re;pure/sockets;pure/typetraits"