diff --git a/nbdev/config.py b/nbdev/config.py index 20136c830..e065f7351 100644 --- a/nbdev/config.py +++ b/nbdev/config.py @@ -63,7 +63,6 @@ def _apply_defaults( clear_all:bool_arg=False, # Remove all cell metadata and cell outputs? cell_number:bool_arg=True, # Add cell number to the exported file put_version_in_init:bool_arg=True, # Add the version to the main __init__.py in nbdev_export - keep_magics:bool = False, # Keep magic commands in rendered documentation (useful for AImagic notebooks) ): "Apply default settings where missing in `cfg`." if getattr(cfg,'repo',None) is None: diff --git a/nbdev/processors.py b/nbdev/processors.py index 2d81abd4e..a55c0204c 100644 --- a/nbdev/processors.py +++ b/nbdev/processors.py @@ -183,8 +183,7 @@ def ai_magics(cell): def clean_magics(cell): "A preprocessor to remove cell magic commands" - if cell.cell_type == 'code' and not get_config().get('keep_magics', False): - cell.source = _magics_pattern.sub('', cell.source).strip() + if cell.cell_type == 'code': cell.source = _magics_pattern.sub('', cell.source).strip() # %% ../nbs/api/10_processors.ipynb _re_hdr_dash = re.compile(r'^#+\s+.*\s+-\s*$', re.MULTILINE) diff --git a/nbs/api/01_config.ipynb b/nbs/api/01_config.ipynb index 7ca54848d..d5e44facb 100644 --- a/nbs/api/01_config.ipynb +++ b/nbs/api/01_config.ipynb @@ -153,7 +153,6 @@ " clear_all:bool_arg=False, # Remove all cell metadata and cell outputs?\n", " cell_number:bool_arg=True, # Add cell number to the exported file\n", " put_version_in_init:bool_arg=True, # Add the version to the main __init__.py in nbdev_export\n", - " keep_magics:bool = False, # Keep magic commands in rendered documentation (useful for AImagic notebooks)\n", "):\n", " \"Apply default settings where missing in `cfg`.\"\n", " if getattr(cfg,'repo',None) is None:\n", @@ -196,7 +195,16 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/dienhoa/miniconda3/envs/se/lib/python3.9/site-packages/ghapi/core.py:102: UserWarning: Neither GITHUB_TOKEN nor GITHUB_JWT_TOKEN found: running as unauthenticated\n", + " else: warn('Neither GITHUB_TOKEN nor GITHUB_JWT_TOKEN found: running as unauthenticated')\n" + ] + } + ], "source": [ "#|hide\n", "if os.getenv('GITHUB_ACTIONS') != 'true': # GITHUB_TOKEN in actions has limited scope.\n", diff --git a/nbs/api/10_processors.ipynb b/nbs/api/10_processors.ipynb index fd4a66de7..1dc554925 100644 --- a/nbs/api/10_processors.ipynb +++ b/nbs/api/10_processors.ipynb @@ -578,8 +578,7 @@ "\n", "def clean_magics(cell):\n", " \"A preprocessor to remove cell magic commands\"\n", - " if cell.cell_type == 'code' and not get_config().get('keep_magics', False):\n", - " cell.source = _magics_pattern.sub('', cell.source).strip()" + " if cell.cell_type == 'code': cell.source = _magics_pattern.sub('', cell.source).strip()" ] }, {