Testing `%nbdev_add2all` and showing how it works.

It used to be the case that everything in _all_ had to be quoted.

We now use flags.parse_line for _all_ so you can use code completion etc

The cell above gets written to lib as:

__all__ = ['_not_included_by_default']

%nbdev_add2all can work with anything that could come after _all_=.

You can use square brackets ...

def _not_included_by_default2(): pass
%nbdev_add2all ["_not_included_by_default2"]

... but you don't have to

It's still true that only the first _all_ or %nbdev_add2all gets picked up by export

You'll see warnings if the list of names is missing ...

UsageError: List of names is missing. Usage `%nbdev_add2all name_1, name_2`

... or if names fail to eval

 
UsageError: name 'bad_name' is not defined

... but none of these warnings would cause notebook2script or nbdev_build_lib to fail.

You can use space and/or comma separation

 

and have any amount of other code in a "add2all" cell

As before, only zero indented flags get picked up.

In the following example, show_doc would not be added to __all__ and the module would be broken - because we export everything after %nbdev_export (including %nbdev_add2all show_doc)

%nbdev_export
if True:
    %nbdev_add2all show_doc
    _all_=[show_doc]