diff options
author | Araq <rumpf_a@web.de> | 2012-06-23 16:32:14 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-06-23 16:32:14 +0200 |
commit | 3c985184876f47127dc055d7e7661f228e261d22 (patch) | |
tree | 7293f79a772c14dfd6b285af22050d325ef99e1f | |
parent | 0e936cbabd6b97132778a2d0644195b3ba495d9d (diff) | |
download | Nim-3c985184876f47127dc055d7e7661f228e261d22.tar.gz |
docgen2 improvements
-rwxr-xr-x | compiler/docgen.nim | 8 | ||||
-rwxr-xr-x | compiler/main.nim | 2 | ||||
-rwxr-xr-x | compiler/renderer.nim | 18 | ||||
-rwxr-xr-x | lib/system/atomics.nim | 2 | ||||
-rw-r--r-- | lib/system/avltree.nim | 2 | ||||
-rwxr-xr-x | lib/system/inclrtl.nim | 4 | ||||
-rwxr-xr-x | lib/system/sysio.nim | 6 |
7 files changed, 28 insertions, 14 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim index d0d551f19..69e61db99 100755 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -18,7 +18,7 @@ import type TSections = array[TSymKind, PRope] - TDocumentor* = object of rstgen.TRstGenerator + TDocumentor = object of rstgen.TRstGenerator modDesc: PRope # module description id: int # for generating IDs toc, section: TSections @@ -148,12 +148,12 @@ proc isVisible(n: PNode): bool = result = {sfExported, sfFromGeneric, sfForward}*n.sym.flags == {sfExported} elif n.kind == nkPragmaExpr: result = isVisible(n.sons[0]) - + proc getName(d: PDoc, n: PNode, splitAfter = -1): string = case n.kind of nkPostfix: result = getName(d, n.sons[1], splitAfter) of nkPragmaExpr: result = getName(d, n.sons[0], splitAfter) - of nkSym: result = esc(d.target, n.sym.name.s, splitAfter) + of nkSym: result = esc(d.target, n.sym.renderDefinitionName, splitAfter) of nkIdent: result = esc(d.target, n.ident.s, splitAfter) of nkAccQuoted: result = esc(d.target, "`") @@ -167,7 +167,7 @@ proc getRstName(n: PNode): PRstNode = case n.kind of nkPostfix: result = getRstName(n.sons[1]) of nkPragmaExpr: result = getRstName(n.sons[0]) - of nkSym: result = newRstNode(rnLeaf, n.sym.name.s) + of nkSym: result = newRstNode(rnLeaf, n.sym.renderDefinitionName) of nkIdent: result = newRstNode(rnLeaf, n.ident.s) of nkAccQuoted: result = getRstName(n.sons[0]) diff --git a/compiler/main.nim b/compiler/main.nim index ad1d55cb4..0675142fa 100755 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -107,7 +107,7 @@ proc CommandDoc2 = msgs.gErrorMax = high(int) # do not stop after first error semanticPasses() registerPass(docgen2Pass()) - registerPass(cleanupPass()) + #registerPass(cleanupPass()) compileProject(mainCommandArg()) finishDoc2Pass(gProjectFull) diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 9a5538c1c..30daf7c52 100755 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -44,6 +44,17 @@ proc getNextTok*(r: var TSrcGen, kind: var TTokType, literal: var string) # determines how long the subtree will likely be, the second # phase appends to a buffer that will be the output. +proc isKeyword*(s: string): bool = + var i = getIdent(s) + if (i.id >= ord(tokKeywordLow) - ord(tkSymbol)) and + (i.id <= ord(tokKeywordHigh) - ord(tkSymbol)): + result = true + +proc renderDefinitionName*(s: PSym): string = + let x = s.name.s + if x[0] in SymStartChars and not renderer.isKeyword(x): result = x + else: result = '`' & x & '`' + const IndentWidth = 2 longIndentWid = 4 @@ -633,11 +644,14 @@ proc gcase(g: var TSrcGen, n: PNode) = proc gproc(g: var TSrcGen, n: PNode) = var c: TContext - gsub(g, n.sons[0]) + if n.sons[namePos].kind == nkSym: + put(g, tkSymbol, renderDefinitionName(n.sons[namePos].sym)) + else: + gsub(g, n.sons[namePos]) gsub(g, n.sons[1]) gsub(g, n.sons[2]) gsub(g, n.sons[3]) - if not (renderNoBody in g.flags): + if renderNoBody notin g.flags: if n.sons[4].kind != nkEmpty: put(g, tkSpaces, Space) putWithSpace(g, tkEquals, "=") diff --git a/lib/system/atomics.nim b/lib/system/atomics.nim index b2e1b6bba..127a8637f 100755 --- a/lib/system/atomics.nim +++ b/lib/system/atomics.nim @@ -7,7 +7,7 @@ # distribution, for details about the copyright. # -## Atomic operations for Nimrod. +# Atomic operations for Nimrod. when (defined(gcc) or defined(llvm_gcc)) and hasThreadSupport and not defined(windows): diff --git a/lib/system/avltree.nim b/lib/system/avltree.nim index dcd6c917d..6a268b453 100644 --- a/lib/system/avltree.nim +++ b/lib/system/avltree.nim @@ -7,7 +7,7 @@ # distribution, for details about the copyright. # -## not really an AVL tree anymore, but still balanced ... +# not really an AVL tree anymore, but still balanced ... template IsBottom(n: PAvlNode): bool = n == bottom diff --git a/lib/system/inclrtl.nim b/lib/system/inclrtl.nim index f113430be..d9dfd3aa2 100755 --- a/lib/system/inclrtl.nim +++ b/lib/system/inclrtl.nim @@ -7,8 +7,8 @@ # distribution, for details about the copyright. # -## Pragmas for RTL generation. Has to be an include, because user-defined -## pragmas cannot be exported. +# Pragmas for RTL generation. Has to be an include, because user-defined +# pragmas cannot be exported. # There are 3 different usages: # 1) Ordinary imported code. diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index 0180bcdae..adcb32b42 100755 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -8,9 +8,9 @@ # -## Nimrod's standard IO library. It contains high-performance -## routines for reading and writing data to (buffered) files or -## TTYs. +# Nimrod's standard IO library. It contains high-performance +# routines for reading and writing data to (buffered) files or +# TTYs. {.push debugger:off .} # the user does not want to trace a part # of the standard library! |