Open mthuurne opened 3 years ago
with accurate line number information we could pick the right slice from the original source file
No idea how you would do that!
This sounds like a very hard task for limited benefits. But maybe I'm mistaken.
We could try to integrate with ASTTokens: https://asttokens.readthedocs.io/en/latest/api-index.html#asttokens.ASTTokens.get_tokens and use it in the colorizer.
This probably means larger refactorings.
The source of
twisted.internet.posixbase.PosixReactorBase
reads:But this is formatted in pydoctor as:
While decimal 438 is the same value as octal 666, the meaning of
0o666
is immediately clear to someone familiar with POSIX file modes while that is not the case for438
.The AST does not contain the original formatting of a constant, only the value. However, with accurate line number information we could pick the right slice from the original source file and present that instead.
In theory we could do the same for other literals, but I'm not sure if it would be as useful there as it is for integers.