docgen2 improvements
This commit is contained in:
parent
0e936cbabd
commit
3c98518487
7 changed files with 28 additions and 14 deletions
|
|
@ -18,7 +18,7 @@ import
|
||||||
|
|
||||||
type
|
type
|
||||||
TSections = array[TSymKind, PRope]
|
TSections = array[TSymKind, PRope]
|
||||||
TDocumentor* = object of rstgen.TRstGenerator
|
TDocumentor = object of rstgen.TRstGenerator
|
||||||
modDesc: PRope # module description
|
modDesc: PRope # module description
|
||||||
id: int # for generating IDs
|
id: int # for generating IDs
|
||||||
toc, section: TSections
|
toc, section: TSections
|
||||||
|
|
@ -153,7 +153,7 @@ proc getName(d: PDoc, n: PNode, splitAfter = -1): string =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkPostfix: result = getName(d, n.sons[1], splitAfter)
|
of nkPostfix: result = getName(d, n.sons[1], splitAfter)
|
||||||
of nkPragmaExpr: result = getName(d, n.sons[0], 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 nkIdent: result = esc(d.target, n.ident.s, splitAfter)
|
||||||
of nkAccQuoted:
|
of nkAccQuoted:
|
||||||
result = esc(d.target, "`")
|
result = esc(d.target, "`")
|
||||||
|
|
@ -167,7 +167,7 @@ proc getRstName(n: PNode): PRstNode =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkPostfix: result = getRstName(n.sons[1])
|
of nkPostfix: result = getRstName(n.sons[1])
|
||||||
of nkPragmaExpr: result = getRstName(n.sons[0])
|
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 nkIdent: result = newRstNode(rnLeaf, n.ident.s)
|
||||||
of nkAccQuoted:
|
of nkAccQuoted:
|
||||||
result = getRstName(n.sons[0])
|
result = getRstName(n.sons[0])
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ proc CommandDoc2 =
|
||||||
msgs.gErrorMax = high(int) # do not stop after first error
|
msgs.gErrorMax = high(int) # do not stop after first error
|
||||||
semanticPasses()
|
semanticPasses()
|
||||||
registerPass(docgen2Pass())
|
registerPass(docgen2Pass())
|
||||||
registerPass(cleanupPass())
|
#registerPass(cleanupPass())
|
||||||
compileProject(mainCommandArg())
|
compileProject(mainCommandArg())
|
||||||
finishDoc2Pass(gProjectFull)
|
finishDoc2Pass(gProjectFull)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
# determines how long the subtree will likely be, the second
|
||||||
# phase appends to a buffer that will be the output.
|
# 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
|
const
|
||||||
IndentWidth = 2
|
IndentWidth = 2
|
||||||
longIndentWid = 4
|
longIndentWid = 4
|
||||||
|
|
@ -633,11 +644,14 @@ proc gcase(g: var TSrcGen, n: PNode) =
|
||||||
|
|
||||||
proc gproc(g: var TSrcGen, n: PNode) =
|
proc gproc(g: var TSrcGen, n: PNode) =
|
||||||
var c: TContext
|
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[1])
|
||||||
gsub(g, n.sons[2])
|
gsub(g, n.sons[2])
|
||||||
gsub(g, n.sons[3])
|
gsub(g, n.sons[3])
|
||||||
if not (renderNoBody in g.flags):
|
if renderNoBody notin g.flags:
|
||||||
if n.sons[4].kind != nkEmpty:
|
if n.sons[4].kind != nkEmpty:
|
||||||
put(g, tkSpaces, Space)
|
put(g, tkSpaces, Space)
|
||||||
putWithSpace(g, tkEquals, "=")
|
putWithSpace(g, tkEquals, "=")
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
## Atomic operations for Nimrod.
|
# Atomic operations for Nimrod.
|
||||||
|
|
||||||
when (defined(gcc) or defined(llvm_gcc)) and hasThreadSupport and
|
when (defined(gcc) or defined(llvm_gcc)) and hasThreadSupport and
|
||||||
not defined(windows):
|
not defined(windows):
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# distribution, for details about the copyright.
|
# 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
|
template IsBottom(n: PAvlNode): bool = n == bottom
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
## Pragmas for RTL generation. Has to be an include, because user-defined
|
# Pragmas for RTL generation. Has to be an include, because user-defined
|
||||||
## pragmas cannot be exported.
|
# pragmas cannot be exported.
|
||||||
|
|
||||||
# There are 3 different usages:
|
# There are 3 different usages:
|
||||||
# 1) Ordinary imported code.
|
# 1) Ordinary imported code.
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
## Nimrod's standard IO library. It contains high-performance
|
# Nimrod's standard IO library. It contains high-performance
|
||||||
## routines for reading and writing data to (buffered) files or
|
# routines for reading and writing data to (buffered) files or
|
||||||
## TTYs.
|
# TTYs.
|
||||||
|
|
||||||
{.push debugger:off .} # the user does not want to trace a part
|
{.push debugger:off .} # the user does not want to trace a part
|
||||||
# of the standard library!
|
# of the standard library!
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue