merged better html links #850

This commit is contained in:
Araq 2014-04-08 01:19:15 +02:00
commit 3e25d5f247
13 changed files with 559 additions and 56 deletions

View file

@ -15,7 +15,7 @@ import
type
TRenderFlag* = enum
renderNone, renderNoBody, renderNoComments, renderDocComments,
renderNoPragmas, renderIds
renderNoPragmas, renderIds, renderNoProcDefs
TRenderFlags* = set[TRenderFlag]
TRenderTok*{.final.} = object
kind*: TTokType
@ -51,10 +51,17 @@ proc isKeyword*(s: string): bool =
(i.id <= ord(tokKeywordHigh) - ord(tkSymbol)):
result = true
proc renderDefinitionName*(s: PSym): string =
proc renderDefinitionName*(s: PSym, noQuotes = false): string =
## Returns the definition name of the symbol.
##
## If noQuotes is false the symbol may be returned in backticks. This will
## happen if the name happens to be a keyword or the first character is not
## part of the SymStartChars set.
let x = s.name.s
if x[0] in SymStartChars and not renderer.isKeyword(x): result = x
else: result = '`' & x & '`'
if noQuotes or (x[0] in SymStartChars and not renderer.isKeyword(x)):
result = x
else:
result = '`' & x & '`'
const
IndentWidth = 2
@ -1119,22 +1126,22 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
of nkStaticStmt: gstaticStmt(g, n)
of nkAsmStmt: gasm(g, n)
of nkProcDef:
putWithSpace(g, tkProc, "proc")
if renderNoProcDefs notin g.flags: putWithSpace(g, tkProc, "proc")
gproc(g, n)
of nkConverterDef:
putWithSpace(g, tkConverter, "converter")
if renderNoProcDefs notin g.flags: putWithSpace(g, tkConverter, "converter")
gproc(g, n)
of nkMethodDef:
putWithSpace(g, tkMethod, "method")
if renderNoProcDefs notin g.flags: putWithSpace(g, tkMethod, "method")
gproc(g, n)
of nkIteratorDef:
putWithSpace(g, tkIterator, "iterator")
if renderNoProcDefs notin g.flags: putWithSpace(g, tkIterator, "iterator")
gproc(g, n)
of nkMacroDef:
putWithSpace(g, tkMacro, "macro")
if renderNoProcDefs notin g.flags: putWithSpace(g, tkMacro, "macro")
gproc(g, n)
of nkTemplateDef:
putWithSpace(g, tkTemplate, "template")
if renderNoProcDefs notin g.flags: putWithSpace(g, tkTemplate, "template")
gproc(g, n)
of nkTypeSection:
gsection(g, n, emptyContext, tkType, "type")
@ -1336,4 +1343,3 @@ proc getNextTok(r: var TSrcGen, kind: var TTokType, literal: var string) =
inc(r.idx)
else:
kind = tkEof