mkdocstrings / pytkdocs

Load Python objects documentation.
https://mkdocstrings.github.io/pytkdocs
ISC License
50 stars 32 forks source link

Implement terminal colors for Windows #112

Closed ArneBachmannDLR closed 3 years ago

ArneBachmannDLR commented 3 years ago

Log output is messed up on Windows, as it contains control characters targetting Linux-style terminals:

←[33mWARNING  -  ←[0mmkdocs_autorefs.plugin: cookbook-reference.md: Could not find cross-reference target '['a']'
←[33mWARNING  -  ←[0mmkdocs_autorefs.plugin: cookbook-reference.md: Could not find cross-reference target '['a']'

Describe the solution you'd like I think there is a library for system-independent coloring, called colorama. It has a special API to choose colors, but it solves the problem.

Describe alternatives you've considered Disable the coloring control characters on Windows altogether.

pawamoy commented 3 years ago

The color codes you see in the output come from MkDocs, not pytkdocs (nor mkdocstrings). The fact that your terminal does not interpret them is another issue. The thing is, and it's only my opinion based on experience, ANSI support on Windows is a mess. I've seen it work one day, and stop working the next day. It depends on environment variables, registry values, the terminal you are using, the shell you are using, etc. It's hacks over hacks over hacks :grinning:

Try to install and use https://github.com/Microsoft/Terminal, which is better than most other consoles on Windows. But no guarantee to have it interpret ANSI sequences correctly either.

Closing since it's not related to pytkdocs!