It is actually possible if you don't mind using undocumented behavior of 
getImpl (the docs say it works only for procedures and constants, but that 
doesn't seem to be true):
    
    
    # a.nim
    type Mock* = object
    
    # b.nim
    import macros, strutils
    import a as al
    
    type
      # Just to prove that module and symbol aliases are transparent.
      MockAlias = al.Mock
    
    proc XYZ(sym: NimNode): string =
      let
        ts = sym.getType[1]
        fn = ts.symbol.getImpl.lineInfoObj.filename
      result = "`$1 <http://nim-lang.org/docs/$2.html#$1>`_".format(
        ts.symbol, fn.substr(0, fn.find('.') - 1)
      )
    
    macro add2docs(docs, sym: typed): typed =
      newCommentStmtNode(docs.strVal.format(XYZ(sym)))
    
    proc initMock*(m: var MockAlias) =
      "$1 constructor".add2docs(MockAlias)
      echo "initializing.."
    

Reply via email to