Skip to content

Commit

Permalink
fixes #879
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Aug 16, 2022
1 parent 3c0d843 commit 8b7dd15
Show file tree
Hide file tree
Showing 33 changed files with 59 additions and 77 deletions.
11 changes: 10 additions & 1 deletion nbdev/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'clean_ids': 'True',
'conda_requirements': 'pyyaml',
'conda_user': 'fastai',
'console_scripts': 'nbdev_create_config=nbdev.read:nbdev_create_config\n'
'console_scripts': 'nbdev_create_config=nbdev.config:nbdev_create_config\n'
'nbdev_update=nbdev.sync:nbdev_update\n'
'nbdev_export=nbdev.doclinks:nbdev_export\n'
'nbdev_fix=nbdev.merge:nbdev_fix\n'
Expand Down Expand Up @@ -82,6 +82,15 @@
'nbdev.cli.nbdev_new': 'https://nbdev.fast.ai/cli.html#nbdev_new',
'nbdev.cli.prepare': 'https://nbdev.fast.ai/cli.html#prepare',
'nbdev.cli.prompt_user': 'https://nbdev.fast.ai/cli.html#prompt_user'},
'nbdev.config': { 'nbdev.config.add_init': 'https://nbdev.fast.ai/config.html#add_init',
'nbdev.config.basic_export_nb': 'https://nbdev.fast.ai/config.html#basic_export_nb',
'nbdev.config.config_key': 'https://nbdev.fast.ai/config.html#config_key',
'nbdev.config.create_output': 'https://nbdev.fast.ai/config.html#create_output',
'nbdev.config.get_config': 'https://nbdev.fast.ai/config.html#get_config',
'nbdev.config.nbdev_create_config': 'https://nbdev.fast.ai/config.html#nbdev_create_config',
'nbdev.config.show_src': 'https://nbdev.fast.ai/config.html#show_src',
'nbdev.config.update_version': 'https://nbdev.fast.ai/config.html#update_version',
'nbdev.config.write_cells': 'https://nbdev.fast.ai/config.html#write_cells'},
'nbdev.doclinks': { 'nbdev.doclinks.DocLinks': 'https://nbdev.fast.ai/doclinks.html#doclinks',
'nbdev.doclinks.DocLinks.build_index': 'https://nbdev.fast.ai/doclinks.html#doclinks.build_index',
'nbdev.doclinks.DocLinks.update_syms': 'https://nbdev.fast.ai/doclinks.html#doclinks.update_syms',
Expand Down
2 changes: 1 addition & 1 deletion nbdev/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from fastcore.imports import *

from .imports import *
from .read import *
from .config import *
from .sync import *
from .process import first_code_ln

Expand Down
6 changes: 2 additions & 4 deletions nbdev/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from __future__ import annotations
import warnings

from .read import *
from .sync import *
from .config import *
from .process import *
from .processors import *
from .doclinks import *
Expand All @@ -19,10 +18,9 @@
from fastcore.style import S
from fastcore.shutil import rmtree,move

from os import system
from urllib.error import HTTPError
from contextlib import redirect_stdout
import os, tarfile, subprocess, sys
import os, tarfile, sys

# %% auto 0
__all__ = ['prepare', 'FilterDefaults', 'nbdev_filter', 'extract_tgz', 'prompt_user', 'nbdev_new', 'chelp']
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion nbdev/doclinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__all__ = ['DocLinks', 'get_patch_name', 'build_modidx', 'nbglob', 'nbdev_export', 'NbdevLookup']

# %% ../nbs/04b_doclinks.ipynb 2
from .read import *
from .config import *
from .maker import *
from .export import *
from .imports import *
Expand Down
2 changes: 1 addition & 1 deletion nbdev/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__all__ = ['ExportModuleProc', 'black_format', 'create_modules', 'nb_export']

# %% ../nbs/04a_export.ipynb 2
from .read import *
from .config import *
from .maker import *
from .imports import *
from .process import *
Expand Down
2 changes: 1 addition & 1 deletion nbdev/maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'update_import', 'basic_export_nb2']

# %% ../nbs/02_maker.ipynb 4
from .read import *
from .config import *
from .imports import *

from fastcore.script import *
Expand Down
2 changes: 1 addition & 1 deletion nbdev/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# %% ../nbs/06_merge.ipynb 2
from .imports import *
from .read import *
from .config import *
from .export import *
from .sync import *

Expand Down
2 changes: 1 addition & 1 deletion nbdev/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# %% ../nbs/15_migrate.ipynb 2
from .process import first_code_ln
from .processors import nb_fmdict, construct_fm, insert_frontmatter, is_frontmatter, yml2dict, filter_fm
from .read import get_config, read_nb
from .config import get_config, read_nb
from .sync import write_nb
from .clean import process_write
from .showdoc import show_doc
Expand Down
2 changes: 1 addition & 1 deletion nbdev/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__all__ = ['langs', 'nb_lang', 'first_code_ln', 'extract_directives', 'opt_set', 'instantiate', 'NBProcessor', 'Processor']

# %% ../nbs/03_process.ipynb 2
from .read import *
from .config import *
from .maker import *
from .imports import *

Expand Down
2 changes: 1 addition & 1 deletion nbdev/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# %% ../nbs/09_processors.ipynb 2
import ast

from .read import *
from .config import *
from .imports import *
from .process import *
from .showdoc import *
Expand Down
39 changes: 16 additions & 23 deletions nbdev/quarto.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,28 @@
from __future__ import annotations
import warnings

from .read import *
from .sync import *
from .process import *
from .processors import *
from .config import *
from .doclinks import *
from .test import *
from .clean import *

from execnb.nbio import *
from fastcore.utils import *
from fastcore.script import call_parse
from fastcore.style import S
from fastcore.shutil import rmtree,move

from os import system
import os, subprocess, sys, shutil
import subprocess,sys,shutil

# %% auto 0
__all__ = ['BASE_QUARTO_URL', 'install_quarto', 'install', 'nbdev_sidebar', 'nbdev_readme', 'refresh_quarto_yml', 'nbdev_quarto',
'preview', 'deploy']

# %% ../nbs/13_quarto.ipynb 5
# %% ../nbs/13_quarto.ipynb 4
_def_file_re = '\.(?:ipynb|qmd|html)$'

def _sprun(cmd):
try: subprocess.check_output(cmd, shell=True)
except subprocess.CalledProcessError as cpe: sys.exit(cpe.returncode)

# %% ../nbs/13_quarto.ipynb 6
# %% ../nbs/13_quarto.ipynb 5
BASE_QUARTO_URL='https://www.quarto.org/download/latest/'

def _install_linux():
Expand All @@ -57,15 +50,15 @@ def install_quarto():
elif 'linux' in sys.platform: _install_linux()
finally: system('sudo rm -f .installing')

# %% ../nbs/13_quarto.ipynb 7
# %% ../nbs/13_quarto.ipynb 6
@call_parse
def install():
"Install Quarto and the current library"
install_quarto.__wrapped__()
d = get_config().path('lib_path')
if (d/'__init__.py').exists(): system(f'pip install -e "{d.parent}[dev]"')

# %% ../nbs/13_quarto.ipynb 8
# %% ../nbs/13_quarto.ipynb 7
def _doc_paths(path:str=None, doc_path:str=None):
cfg = get_config()
cfg_path = cfg.config_path
Expand All @@ -74,15 +67,15 @@ def _doc_paths(path:str=None, doc_path:str=None):
tmp_doc_path = path/f"{cfg['doc_path']}"
return cfg,cfg_path,path,doc_path,tmp_doc_path

# %% ../nbs/13_quarto.ipynb 9
# %% ../nbs/13_quarto.ipynb 8
def _f(a,b): return Path(a),b
def _pre(p,b=True): return ' ' * (len(p.parts)) + ('- ' if b else ' ')
def _sort(a):
x,y = a
if y.startswith('index.'): return x,'00'
return a

# %% ../nbs/13_quarto.ipynb 10
# %% ../nbs/13_quarto.ipynb 9
@call_parse
def nbdev_sidebar(
path:str=None, # Path to notebooks
Expand Down Expand Up @@ -118,7 +111,7 @@ def nbdev_sidebar(
yml_path.write_text(yml)
if returnit: return files

# %% ../nbs/13_quarto.ipynb 12
# %% ../nbs/13_quarto.ipynb 11
def _render_readme(path):
idx_path = path/get_config().readme_nb
if not idx_path.exists(): return
Expand All @@ -134,7 +127,7 @@ def _render_readme(path):
finally:
if moved: (path/'sidebar.yml.bak').rename(yml_path)

# %% ../nbs/13_quarto.ipynb 13
# %% ../nbs/13_quarto.ipynb 12
@call_parse
def nbdev_readme(
path:str=None, # Path to notebooks
Expand All @@ -147,13 +140,13 @@ def nbdev_readme(
if _rdm.exists(): _rdm.unlink() # py37 doesn't have arg missing_ok so have to check first
move(str(tmp_doc_path/'README.md'), cfg_path) # README.md is temporarily in nbs/_docs

# %% ../nbs/13_quarto.ipynb 14
# %% ../nbs/13_quarto.ipynb 13
def _ensure_quarto():
if shutil.which('quarto'): return
print("Quarto is not installed. We will download and install it for you.")
install.__wrapped__()

# %% ../nbs/13_quarto.ipynb 15
# %% ../nbs/13_quarto.ipynb 14
_quarto_yml="""ipynb-filters: [nbdev_filter]
project:
Expand Down Expand Up @@ -194,7 +187,7 @@ def _ensure_quarto():
- custom.yml
"""

# %% ../nbs/13_quarto.ipynb 16
# %% ../nbs/13_quarto.ipynb 15
def refresh_quarto_yml():
"Generate `_quarto.yml` from `settings.ini`."
cfg = get_config()
Expand All @@ -206,7 +199,7 @@ def refresh_quarto_yml():
yml=_quarto_yml.format(**vals)
p.write_text(yml)

# %% ../nbs/13_quarto.ipynb 17
# %% ../nbs/13_quarto.ipynb 16
@call_parse
def nbdev_quarto(
path:str=None, # Path to notebooks
Expand All @@ -233,7 +226,7 @@ def nbdev_quarto(
rmtree(doc_path, ignore_errors=True)
move(tmp_doc_path, cfg_path)

# %% ../nbs/13_quarto.ipynb 18
# %% ../nbs/13_quarto.ipynb 17
@call_parse
def preview(
path:str=None, # Path to notebooks
Expand All @@ -249,7 +242,7 @@ def preview(
nbdev_quarto.__wrapped__(path, doc_path=doc_path, symlinks=symlinks, file_re=file_re, folder_re=folder_re,
skip_file_glob=skip_file_glob, skip_file_re=skip_file_re, preview=True, port=port)

# %% ../nbs/13_quarto.ipynb 19
# %% ../nbs/13_quarto.ipynb 18
@call_parse
def deploy(
path:str=None, # Path to notebooks
Expand Down
2 changes: 1 addition & 1 deletion nbdev/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def release_gh(

# %% ../nbs/17_release.ipynb 33
from fastcore.all import *
from .read import *
from .config import *
from .cli import *

import yaml,subprocess,glob,platform
Expand Down
2 changes: 1 addition & 1 deletion nbdev/showdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# %% ../nbs/08_showdoc.ipynb 2
from __future__ import annotations
from .doclinks import *
from .read import get_config
from .config import get_config

from fastcore.dispatch import TypeDispatch
from fastcore.docments import *
Expand Down
2 changes: 1 addition & 1 deletion nbdev/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# %% ../nbs/05_sync.ipynb 3
from .imports import *
from .read import *
from .config import *
from .maker import *
from .process import *
from .export import *
Expand Down
2 changes: 1 addition & 1 deletion nbdev/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from fastcore.parallel import *
from fastcore.script import *

from .read import *
from .config import *
from .doclinks import *
from .process import NBProcessor, nb_lang
from .processors import infer_frontmatter
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion nbs/02_maker.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"outputs": [],
"source": [
"#|export\n",
"from nbdev.read import *\n",
"from nbdev.config import *\n",
"from nbdev.imports import *\n",
"\n",
"from fastcore.script import *\n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/03_process.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"outputs": [],
"source": [
"#|export\n",
"from nbdev.read import *\n",
"from nbdev.config import *\n",
"from nbdev.maker import *\n",
"from nbdev.imports import *\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/04a_export.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"outputs": [],
"source": [
"#|export\n",
"from nbdev.read import *\n",
"from nbdev.config import *\n",
"from nbdev.maker import *\n",
"from nbdev.imports import *\n",
"from nbdev.process import *\n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/04b_doclinks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"outputs": [],
"source": [
"#|export\n",
"from nbdev.read import *\n",
"from nbdev.config import *\n",
"from nbdev.maker import *\n",
"from nbdev.export import *\n",
"from nbdev.imports import *\n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/05_sync.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"source": [
"#|export\n",
"from nbdev.imports import *\n",
"from nbdev.read import *\n",
"from nbdev.config import *\n",
"from nbdev.maker import *\n",
"from nbdev.process import *\n",
"from nbdev.export import *\n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/06_merge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"source": [
"#|export\n",
"from nbdev.imports import *\n",
"from nbdev.read import *\n",
"from nbdev.config import *\n",
"from nbdev.export import *\n",
"from nbdev.sync import *\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/08_showdoc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"#|export\n",
"from __future__ import annotations\n",
"from nbdev.doclinks import *\n",
"from nbdev.read import get_config\n",
"from nbdev.config import get_config\n",
"\n",
"from fastcore.dispatch import TypeDispatch\n",
"from fastcore.docments import *\n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/09_processors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"#|export\n",
"import ast\n",
"\n",
"from nbdev.read import *\n",
"from nbdev.config import *\n",
"from nbdev.imports import *\n",
"from nbdev.process import *\n",
"from nbdev.showdoc import *\n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/10_clean.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"from fastcore.imports import *\n",
"\n",
"from nbdev.imports import *\n",
"from nbdev.read import *\n",
"from nbdev.config import *\n",
"from nbdev.sync import *\n",
"from nbdev.process import first_code_ln"
]
Expand Down
2 changes: 1 addition & 1 deletion nbs/11_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"from fastcore.parallel import *\n",
"from fastcore.script import *\n",
"\n",
"from nbdev.read import *\n",
"from nbdev.config import *\n",
"from nbdev.doclinks import *\n",
"from nbdev.process import NBProcessor, nb_lang\n",
"from nbdev.processors import infer_frontmatter\n",
Expand Down
Loading

0 comments on commit 8b7dd15

Please sign in to comment.