traitlets icon indicating copy to clipboard operation
traitlets copied to clipboard

Document flag configuration

Open metaperl opened this issue 3 years ago • 2 comments

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.

metaperl avatar Apr 15 '22 07:04 metaperl

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.'
)
``

metaperl avatar Apr 15 '22 15:04 metaperl

More digging. if the docs had linked to the example source code then a lot of the docs would've been easier to follow.

metaperl avatar Apr 16 '22 08:04 metaperl

Docs have been updated a bit, feel free to submit a PR to improve docs if you encounter anything missing.

azjps avatar Jan 30 '23 09:01 azjps