Skip to content

Commit 7401c11

Browse files
authored
Merge pull request #1445 from fastai/skip-procs
add `skip_procs` to `settings.ini`
2 parents d768248 + 1a48c72 commit 7401c11

File tree

5 files changed

+44
-45
lines changed

5 files changed

+44
-45
lines changed

nbdev/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def _apply_defaults(
6363
clear_all:bool_arg=False, # Remove all cell metadata and cell outputs?
6464
cell_number:bool_arg=True, # Add cell number to the exported file
6565
put_version_in_init:bool_arg=True, # Add the version to the main __init__.py in nbdev_export
66+
skip_procs:str='', # A list of processors that you want to skip
6667
):
6768
"Apply default settings where missing in `cfg`."
6869
if getattr(cfg,'repo',None) is None:

nbdev/processors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ def base_procs(self):
282282

283283
def procs(self):
284284
"Processors for export"
285-
return self.base_procs() + self.xtra_procs()
285+
skip_procs = get_config().get('skip_procs', '').split()
286+
return L(self.base_procs()).filter(lambda x: x.__name__ not in skip_procs) + self.xtra_procs()
286287

287288
def nb_proc(self, nb):
288289
"Get an `NBProcessor` with these processors"

nbs/api/01_config.ipynb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
" clear_all:bool_arg=False, # Remove all cell metadata and cell outputs?\n",
154154
" cell_number:bool_arg=True, # Add cell number to the exported file\n",
155155
" put_version_in_init:bool_arg=True, # Add the version to the main __init__.py in nbdev_export\n",
156+
" skip_procs:str='', # A list of processors that you want to skip\n",
156157
"):\n",
157158
" \"Apply default settings where missing in `cfg`.\"\n",
158159
" if getattr(cfg,'repo',None) is None:\n",
@@ -195,16 +196,7 @@
195196
"cell_type": "code",
196197
"execution_count": null,
197198
"metadata": {},
198-
"outputs": [
199-
{
200-
"name": "stderr",
201-
"output_type": "stream",
202-
"text": [
203-
"/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",
204-
" else: warn('Neither GITHUB_TOKEN nor GITHUB_JWT_TOKEN found: running as unauthenticated')\n"
205-
]
206-
}
207-
],
199+
"outputs": [],
208200
"source": [
209201
"#|hide\n",
210202
"if os.getenv('GITHUB_ACTIONS') != 'true': # GITHUB_TOKEN in actions has limited scope.\n",

nbs/api/10_processors.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,8 @@
779779
"\n",
780780
" def procs(self):\n",
781781
" \"Processors for export\"\n",
782-
" return self.base_procs() + self.xtra_procs()\n",
782+
" skip_procs = get_config().get('skip_procs', '').split()\n",
783+
" return L(self.base_procs()).filter(lambda x: x.__name__ not in skip_procs) + self.xtra_procs()\n",
783784
" \n",
784785
" def nb_proc(self, nb):\n",
785786
" \"Get an `NBProcessor` with these processors\"\n",

nbs/explanations/config.ipynb

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
"text": [
4242
"[DEFAULT]\r\n",
4343
"lib_name = nbdev\r\n",
44+
"repo = nbdev\r\n",
4445
"description = Create delightful software with Jupyter Notebooks\r\n",
4546
"copyright = 2020 onwards, Jeremy Howard\r\n",
4647
"keywords = nbdev fastai jupyter notebook export\r\n",
4748
"user = fastai\r\n",
4849
"author = Jeremy Howard and Hamel Husain\r\n",
4950
"author_email = j@fast.ai\r\n",
50-
"branch = master\r\n",
51-
"min_python = 3.7\r\n"
51+
"branch = master\r\n"
5252
]
5353
}
5454
],
@@ -75,39 +75,43 @@
7575
"text/markdown": [
7676
"| | **Type** | **Default** | **Details** |\n",
7777
"| -- | -------- | ----------- | ----------- |\n",
78-
"| user | str | | Repo username |\n",
79-
"| author | str | | Package author's name |\n",
80-
"| author_email | str | | Package author's email address |\n",
81-
"| description | str | | Short summary of the package |\n",
78+
"| repo | str | None | Repo name |\n",
79+
"| branch | str | None | Repo default branch |\n",
80+
"| user | str | None | Repo username |\n",
81+
"| author | str | None | Package author's name |\n",
82+
"| author_email | str | None | Package author's email address |\n",
83+
"| description | str | None | Short summary of the package |\n",
8284
"| path | str | . | Path to create config file |\n",
8385
"| cfg_name | str | settings.ini | Name of config file to create |\n",
84-
"| lib_name | str | None | Package name, defaults to local repo folder name passed to `apply_defaults` |\n",
85-
"| branch | str | master | Repo default branch passed to `apply_defaults` |\n",
86-
"| git_url | str | https://github.com/%(user)s/%(lib_name)s | Repo URL passed to `apply_defaults` |\n",
87-
"| custom_sidebar | bool_arg | False | Use a custom sidebar.yml? passed to `apply_defaults` |\n",
88-
"| nbs_path | str | . | Path to notebooks passed to `apply_defaults` |\n",
89-
"| lib_path | str | %(lib_name)s | Path to package root passed to `apply_defaults` |\n",
90-
"| doc_path | str | _docs | Path to rendered docs passed to `apply_defaults` |\n",
91-
"| tst_flags | str | | Test flags passed to `apply_defaults` |\n",
92-
"| version | str | 0.0.1 | Version of this release passed to `apply_defaults` |\n",
93-
"| doc_host | str | https://%(user)s.github.io | Hostname for docs passed to `apply_defaults` |\n",
94-
"| doc_baseurl | str | /%(lib_name)s | Base URL for docs passed to `apply_defaults` |\n",
95-
"| keywords | str | nbdev jupyter notebook python | Package keywords passed to `apply_defaults` |\n",
96-
"| license | str | apache2 | License for the package passed to `apply_defaults` |\n",
97-
"| copyright | str | None | Copyright for the package, defaults to '`current_year` onwards, `author`' passed to `apply_defaults` |\n",
98-
"| status | str | 3 | Development status PyPI classifier passed to `apply_defaults` |\n",
99-
"| min_python | str | 3.7 | Minimum Python version PyPI classifier passed to `apply_defaults` |\n",
100-
"| audience | str | Developers | Intended audience PyPI classifier passed to `apply_defaults` |\n",
101-
"| language | str | English | Language PyPI classifier passed to `apply_defaults` |\n",
102-
"| recursive | bool_arg | False | Include subfolders in notebook globs? passed to `apply_defaults` |\n",
103-
"| black_formatting | bool_arg | False | Format libraries with black? passed to `apply_defaults` |\n",
104-
"| readme_nb | str | index.ipynb | Notebook to export as repo readme passed to `apply_defaults` |\n",
105-
"| title | str | %(lib_name)s | Quarto website title passed to `apply_defaults` |\n",
106-
"| allowed_metadata_keys | str | | Preserve the list of keys in the main notebook metadata passed to `apply_defaults` |\n",
107-
"| allowed_cell_metadata_keys | str | | Preserve the list of keys in cell level metadata passed to `apply_defaults` |\n",
108-
"| jupyter_hooks | bool | True | Run Jupyter hooks? passed to `apply_defaults` |\n",
109-
"| clean_ids | bool | True | Remove ids from plaintext reprs? passed to `apply_defaults` |\n",
110-
"| custom_quarto_yml | bool | False | Use a custom _quarto.yml? passed to `apply_defaults` |"
86+
"| lib_name | str | %(repo)s | Package name |\n",
87+
"| git_url | str | https://github.com/%(user)s/%(repo)s | Repo URL |\n",
88+
"| custom_sidebar | bool_arg | False | Use a custom sidebar.yml? |\n",
89+
"| nbs_path | Path | nbs | Path to notebooks |\n",
90+
"| lib_path | Path | None | Path to package root (default: `repo` with `-` replaced by `_`) |\n",
91+
"| doc_path | Path | _docs | Path to rendered docs |\n",
92+
"| tst_flags | str | notest | Test flags |\n",
93+
"| version | str | 0.0.1 | Version of this release |\n",
94+
"| doc_host | str | https://%(user)s.github.io | Hostname for docs |\n",
95+
"| doc_baseurl | str | /%(repo)s | Base URL for docs |\n",
96+
"| keywords | str | nbdev jupyter notebook python | Package keywords |\n",
97+
"| license | str | apache2 | License for the package |\n",
98+
"| copyright | str | None | Copyright for the package, defaults to '`current_year` onwards, `author`' |\n",
99+
"| status | str | 3 | Development status PyPI classifier |\n",
100+
"| min_python | str | 3.7 | Minimum Python version PyPI classifier |\n",
101+
"| audience | str | Developers | Intended audience PyPI classifier |\n",
102+
"| language | str | English | Language PyPI classifier |\n",
103+
"| recursive | bool_arg | True | Include subfolders in notebook globs? |\n",
104+
"| black_formatting | bool_arg | False | Format libraries with black? |\n",
105+
"| readme_nb | str | index.ipynb | Notebook to export as repo readme |\n",
106+
"| title | str | %(lib_name)s | Quarto website title |\n",
107+
"| allowed_metadata_keys | str | | Preserve the list of keys in the main notebook metadata |\n",
108+
"| allowed_cell_metadata_keys | str | | Preserve the list of keys in cell level metadata |\n",
109+
"| jupyter_hooks | bool_arg | False | Run Jupyter hooks? |\n",
110+
"| clean_ids | bool_arg | True | Remove ids from plaintext reprs? |\n",
111+
"| clear_all | bool_arg | False | Remove all cell metadata and cell outputs? |\n",
112+
"| cell_number | bool_arg | True | Add cell number to the exported file |\n",
113+
"| put_version_in_init | bool_arg | True | Add the version to the main __init__.py in nbdev_export |\n",
114+
"| skip_procs | str | | A list of processors that you want to skip |"
111115
],
112116
"text/plain": [
113117
"<nbdev.showdoc.DocmentTbl>"

0 commit comments

Comments
 (0)