generated from fastai/nbdev_template
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Utilities for the nbdev library.""" | ||
|
||
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/13_nbdev.ipynb. | ||
|
||
# %% auto 0 | ||
__all__ = ['nbdev_config_file', 'is_nbdev'] | ||
|
||
# %% ../nbs/13_nbdev.ipynb | ||
from .basics import Path | ||
|
||
# %% ../nbs/13_nbdev.ipynb | ||
_nbdev_cfg_name = 'settings.ini' | ||
|
||
def nbdev_config_file(cfg_name=_nbdev_cfg_name, path=None): | ||
"Get the nbdev config file path" | ||
cfg_path = path = Path.cwd() if path is None else Path(path) | ||
while cfg_path != cfg_path.parent and not (cfg_path/cfg_name).exists(): cfg_path = cfg_path.parent | ||
if not (cfg_path/cfg_name).exists(): cfg_path = path | ||
return cfg_path/cfg_name | ||
|
||
# %% ../nbs/13_nbdev.ipynb | ||
def is_nbdev(): | ||
"Checks if the current directory is in a nbdev project." | ||
return nbdev_config_file().exists() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7bea0d2f", | ||
"metadata": {}, | ||
"source": [ | ||
"# nbdev utilities\n", | ||
"> Utilities for the nbdev library." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "07a035a5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|default_exp nbdev" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "75e11db6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|export\n", | ||
"from fastcore.basics import Path" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "558b4d4c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|hide\n", | ||
"from nbdev.export import *\n", | ||
"from fastcore.test import *" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "da2ac196", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|export\n", | ||
"_nbdev_cfg_name = 'settings.ini'\n", | ||
"\n", | ||
"def nbdev_config_file(cfg_name=_nbdev_cfg_name, path=None):\n", | ||
" \"Get the nbdev config file path\"\n", | ||
" cfg_path = path = Path.cwd() if path is None else Path(path)\n", | ||
" while cfg_path != cfg_path.parent and not (cfg_path/cfg_name).exists(): cfg_path = cfg_path.parent\n", | ||
" if not (cfg_path/cfg_name).exists(): cfg_path = path\n", | ||
" return cfg_path/cfg_name" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1c44a414", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|export\n", | ||
"def is_nbdev(): \n", | ||
" \"Checks if the current directory is in a nbdev project.\"\n", | ||
" return nbdev_config_file().exists()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "604a2243", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|hide\n", | ||
"test_eq(is_nbdev(), True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "df973d4e", | ||
"metadata": {}, | ||
"source": [ | ||
"# Export -" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "914d16ca", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|hide\n", | ||
"import nbdev; nbdev.nbdev_export()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "20a20020", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "python3", | ||
"language": "python", | ||
"name": "python3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |