Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect #|hide and #|include: false for showdoc #1079

Merged
merged 2 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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