In 
[cligen.macUt](https://github.com/c-blake/cligen/blob/master/cligen/macUt.nim), 
I have the caller pass a symbol to any `proc` in the module to a `macro 
docFromModuleOf*(sym: typed{nkSym})`. Then that can use `lineInfo` to get a 
pathname and then `staticRead` can slurp the whole file into a `string`.

I only do this to get a default for the overall module doc comment ([example 
call](https://github.com/c-blake/cligen/blob/master/test/MultMultMult.nim)), 
but I suspect you could re-parse the string into an AST with 
`macros.parseStmt`. Then you could iterate over said AST looking for `proc` 
definitions. This is sort of like implementing your own `include`, but one 
where you pass any symbol from the file and then get to intervene at the AST 
level.

I have used this code very little besides the example test case. So, there 
could be issues, but the approach might get you started and that test has never 
failed on me since June 2019. So, it seemed an approach worth mentioning.

Reply via email to