traitlets
traitlets copied to clipboard
Document flag configuration
If one wants to have a boolean attribute of a Configurable/Application set via a flag, there is quite a bit of configuration to do.
Unfortunately, this configuration is not well-documented or exemplified.
I've done some digging. Paring down this code provides a good example of creating boolean flags - https://github.com/ipython/ipython/blob/master/IPython/terminal/ipapp.py
key points:
the boolean_flag helper
from traitlets.config.application import boolean_flag
Creating flags
Further down in same IPython class
frontend_flags = {}
addflag = lambda *args: frontend_flags.update(boolean_flag(*args))
addflag('autoedit-syntax', 'TerminalInteractiveShell.autoedit_syntax',
'Turn on auto editing of files with syntax errors.',
'Turn off auto editing of files with syntax errors.'
)
``
More digging. if the docs had linked to the example source code then a lot of the docs would've been easier to follow.
Docs have been updated a bit, feel free to submit a PR to improve docs if you encounter anything missing.