Skip to content

Commit

Permalink
Merge pull request #1079 from fastai/hide-showdoc
Browse files Browse the repository at this point in the history
respect `#|hide` and `#|include: false` for showdoc
  • Loading branch information
hamelsmu authored Sep 16, 2022
2 parents 09fa92d + 701928b commit 5440471
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 4 additions & 1 deletion nbdev/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ def _show_docs(trees):
return [t for t in trees if isinstance(t,ast.Expr) and nested_attr(t, 'value.func.id')=='show_doc']

def cell_lang(cell): return nested_attr(cell, 'metadata.language', 'python')

def _want_doc(c):
return c.source and c.cell_type=='code' and (set(['export', 'exports', 'exec_doc']).intersection(c.directives_))
d = c.directives_
show_d = set(['export', 'exports', 'exec_doc']).intersection(d)
return c.source and c.cell_type=='code' and show_d and 'hide' not in d and d.get('include:') != ['false']

class add_show_docs(Processor):
"Add show_doc cells after exported cells, unless they are already documented"
Expand Down
13 changes: 4 additions & 9 deletions nbs/api/processors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,11 @@
" return [t for t in trees if isinstance(t,ast.Expr) and nested_attr(t, 'value.func.id')=='show_doc']\n",
"\n",
"def cell_lang(cell): return nested_attr(cell, 'metadata.language', 'python')\n",
"\n",
"def _want_doc(c):\n",
" return c.source and c.cell_type=='code' and (set(['export', 'exports', 'exec_doc']).intersection(c.directives_))\n",
" d = c.directives_\n",
" show_d = set(['export', 'exports', 'exec_doc']).intersection(d)\n",
" return c.source and c.cell_type=='code' and show_d and 'hide' not in d and d.get('include:') != ['false']\n",
"\n",
"class add_show_docs(Processor):\n",
" \"Add show_doc cells after exported cells, unless they are already documented\"\n",
Expand Down Expand Up @@ -653,14 +656,6 @@
"#|hide\n",
"import nbdev; nbdev.nbdev_export()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f05043d0-2dd1-4b12-b07d-63e6b59614aa",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 5440471

Please sign in to comment.