# # # The Nim Compiler # (c) Copyright 2015 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. # import renderer, strutils, ast, msgs, types, astalgo const defaultParamSeparator* = "," proc renderPlainSymbolName*(n: PNode): string = ## Returns the first non '*' nkIdent node from the tree. ## ## Use this on documentation name nodes to extract the *raw* symbol name, ## without decorations, parameters, or anything. That can be used as the base ## for the HTML hyperlinks. result = "" case n.kind of nkPostfix, nkAccQuoted: result = renderPlainSymbolName(n[ 1 let params = n[0] assert params.kind == nkFormalParams assert len(params) > 0 result = "proc(" for i in 1 .. = 3 let typePos = len(n) - 2 let typeStr = renderType(n[typePos]) result = typeStr for i in 1 .. = 2 result = renderType(n[0]) & '[' for i in 1 .. 0 var typeStr = renderType(n[typePos]) if typeStr.len < 1 and n[typePos+1].kind != nkEmpty: # Try with the last node, maybe its a default value. let typ = n[typePos+1].typ if not typ.isNil: typeStr = typeToString(typ, preferExported) if typeStr.len < 1: return for i in 0 .. 0: result = found.join(sep)