Skip to content

Commit 7af5102

Browse files
committed
add card
1 parent f523593 commit 7af5102

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

‎nbdev/processors.py‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/10_processors.ipynb.
22

33
# %% auto 0
4-
__all__ = ['populate_language', 'insert_warning', 'cell_lang', 'add_show_docs', 'mv_exports', 'add_links', 'add_fold',
5-
'strip_ansi', 'strip_hidden_metadata', 'hide_', 'hide_line', 'filter_stream_', 'clean_magics',
6-
'rm_header_dash', 'rm_export', 'clean_show_doc', 'exec_show_docs', 'FilterDefaults']
4+
__all__ = ['CARD_DIV', 'CLOSE_DIV', 'populate_language', 'insert_warning', 'cell_lang', 'add_show_docs', 'mv_exports',
5+
'add_links', 'add_fold', 'strip_ansi', 'strip_hidden_metadata', 'hide_', 'hide_line', 'filter_stream_',
6+
'clean_magics', 'rm_header_dash', 'rm_export', 'clean_show_doc', 'exec_show_docs', 'FilterDefaults']
77

88
# %% ../nbs/api/10_processors.ipynb 2
99
import ast
@@ -83,13 +83,19 @@ def begin(self):
8383
nb.has_docs_ = shown_docs or exports
8484

8585
# %% ../nbs/api/10_processors.ipynb 17
86+
CARD_DIV = mk_cell('::: {.py-2 .px-3 .mb-4 fig-align="center" .border .rounded .shadow-sm}', cell_type='markdown')
87+
CLOSE_DIV = mk_cell(':::', cell_type='markdown')
88+
8689
class mv_exports(Processor):
8790
"Move `exports` cells to after the `show_doc`"
8891
def begin(self):
8992
cells = self.nb.cells
9093
exports = L(c for c in cells if c.cell_type=='code' and 'exports' in c.directives_)
9194
for cell in reversed(exports):
92-
if getattr(cells[cell.idx_+1], 'has_sd', 0): cells.insert(cell.idx_+1, cells.pop(cell.idx_))
95+
if getattr(cells[cell.idx_+1], 'has_sd', 0):
96+
cells.insert(cell.idx_+1, cells.pop(cell.idx_))
97+
cells.insert(cell.idx_, CARD_DIV)
98+
cells.insert(cell.idx_+3, CLOSE_DIV)
9399

94100
# %% ../nbs/api/10_processors.ipynb 18
95101
_re_defaultexp = re.compile(r'^\s*#\|\s*default_exp\s+(\S+)', flags=re.MULTILINE)

‎nbs/api/10_processors.ipynb‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,19 @@
257257
"outputs": [],
258258
"source": [
259259
"#| export\n",
260+
"CARD_DIV = mk_cell('::: {.py-2 .px-3 .mb-4 fig-align=\"center\" .border .rounded .shadow-sm}', cell_type='markdown')\n",
261+
"CLOSE_DIV = mk_cell(':::', cell_type='markdown')\n",
262+
"\n",
260263
"class mv_exports(Processor):\n",
261264
" \"Move `exports` cells to after the `show_doc`\"\n",
262265
" def begin(self):\n",
263266
" cells = self.nb.cells\n",
264267
" exports = L(c for c in cells if c.cell_type=='code' and 'exports' in c.directives_)\n",
265268
" for cell in reversed(exports):\n",
266-
" if getattr(cells[cell.idx_+1], 'has_sd', 0): cells.insert(cell.idx_+1, cells.pop(cell.idx_))"
269+
" if getattr(cells[cell.idx_+1], 'has_sd', 0): \n",
270+
" cells.insert(cell.idx_+1, cells.pop(cell.idx_))\n",
271+
" cells.insert(cell.idx_, CARD_DIV)\n",
272+
" cells.insert(cell.idx_+3, CLOSE_DIV)"
267273
]
268274
},
269275
{
@@ -744,7 +750,7 @@
744750
],
745751
"metadata": {
746752
"kernelspec": {
747-
"display_name": "Python 3 (ipykernel)",
753+
"display_name": "python3",
748754
"language": "python",
749755
"name": "python3"
750756
}

0 commit comments

Comments
 (0)