I'm working on a library that is fairly long. After a single nim file reached
about 2000 lines, I realized a refactoring is way over due.
So I broke the file into four source files. And, in past projects, I could
often abstract the subtending files so that there was no dependency on the main
file. But this one was not so easy because, at a fundamental level, these
source files all depended on a comment set of types.
No problem, I simply but the shared types into a common.nim file and had all of
them, including the main file import from common. The main file also does
`export <blah>` on each of the types so that the user of the library can also
see them. All is good.
Then I used nim doc. Now the very important, and needs to be well documented,
types are no longer part of the generated documentation. Nor can I see a way to
import them into the documentation.
(for procedures, I simply create stubs. Aka `proc abc*(): string =
submoduleA.abc()`. Not the most performant thing to do, but I get my docs
generated.)
I have tried a Linux bash workaround that kind-of-sort-of works with a lot of
tweaking and some oddly conditional compilation weirdness:
excerpt from nimble file (pretending the library is called "main"):
task docgen, "Generate HTML documentation":
exec "cat common.nim main.nim > temp.nim && nim doc -o:doc/main.html
temp.nim && rm temp.nim"
Run
But I'm really not a fan of that as an answer.
Is there a better way to do this?