Reflection for custom docs

I’m trying to write some custom docs. Is there a way of automatically finding all classes and objects in a project and listing all the publicly accessible methods / items (for onward copying into a document)?

What you want is basically a simple compiler, except that you want the output in text, not executable machine-language code. There are automatic compiler-writing tools in the UNIX, Linux worlds, such as YACC. Some of these programs have been made to run under Windows.

No matter what you do, you must start with a Scala grammar, for which you can search. Then the first one or two chapters in any undergraduate compiler text will tell you how to write a parser from the grammar to find exactly what you are looking for. It is not hard. It is exciting and fun, but it is not rocket science.

There’s a Scala parser available as an example of FastParse – that might be a good place to start…

1 Like

Sounds like you may want semanticdb: https://scalameta.org/docs/semanticdb/guide.html#what-is-semanticdb-good-for

semanticdb uses the actual Scala compiler, so compared to the solution path of parsing Scala source code yourself, you don’t have to worry about whether you’re doing it right

2 Likes