doclinks

Generating a documentation index from a module

Create the module index


source

patch_name

 patch_name (o)

If o is decorated with patch or patch_to, return its class-prefix name

def _test_patch(code): return patch_name(ast.parse(code).body[0])
s = "@patch\ndef _f(self:_T): ..."
test_eq('_T._f', _test_patch(s))
s = "@patch_to(_T)\ndef _g(self): ..."
test_eq('_T._g', _test_patch(s))
# Get all patched classes when patching with a union
s = "@patch\ndef _f(self:_T|_U|_V): ..."
test_eq(_test_patch(s), ['_T._f', '_U._f', '_V._f'])
# _build_modidx()

Export a notebook


source

nbglob

 nbglob (path=None, skip_folder_re='^[_.]', file_glob='*.ipynb',
         skip_file_re='^[_.]', key='nbs_path', as_path=False,
         recursive:bool=True, symlinks:bool=True, file_re:str=None,
         folder_re:str=None, skip_file_glob:str=None, func:<built-
         infunctioncallable>=<function join>, ret_folders:bool=False)

Find all files in a directory matching an extension given a config key.

Type Default Details
path Path | str path to start searching
skip_folder_re str None Skip folders matching regex,
file_glob str None Only include files matching glob
skip_file_re str None Skip files matching regex
key str nbs_path
as_path bool False
recursive bool True search subfolders
symlinks bool True follow symlinks?
file_re str None Only include files matching regex
folder_re str None Only enter folders matching regex
skip_file_glob str None Skip files matching glob
func callable join function to apply to each matched file
ret_folders bool False return folders, not just files
Returns L Paths to matched files

source

nbglob_cli

 nbglob_cli (path:str=None, symlinks:bool=False, file_glob:str='*.ipynb',
             file_re:str=None, folder_re:str=None,
             skip_file_glob:str=None, skip_file_re:str='^[_.]',
             skip_folder_re:str='^[_.]')

Find all files in a directory matching an extension given a config key.

Type Default Details
path str None Path to notebooks
symlinks bool False Follow symlinks?
file_glob str *.ipynb Only include files matching glob
file_re str None Only include files matching regex
folder_re str None Only enter folders matching regex
skip_file_glob str None Skip files matching glob
skip_file_re str ^[_.] Skip files matching regex
skip_folder_re str ^[_.] Skip folders matching regex

source

nbdev_export

 nbdev_export (path:str=None,
               procs:<tokensnamingtheexportprocessorstouse.>='black_format
               ', symlinks:bool=False, file_glob:str='*.ipynb',
               file_re:str=None, folder_re:str=None,
               skip_file_glob:str=None, skip_file_re:str='^[_.]',
               skip_folder_re:str='^[_.]')

Export notebooks in path to Python modules

Type Default Details
path str None Path or filename
procs <tokens naming the export processors to use.> black_format
symlinks bool False Follow symlinks?
file_glob str *.ipynb Only include files matching glob
file_re str None Only include files matching regex
folder_re str None Only enter folders matching regex
skip_file_glob str None Skip files matching glob
skip_file_re str ^[_.] Skip files matching regex
skip_folder_re str ^[_.] Skip folders matching regex

procs names the optional processors you wish to run on the exported cells of your notebook.

N.B.: the black_format processor is passed in by default. But it is a no-op, unless black_formatting=True is set in your settings.ini configuration. You can omit it from nbdev_export on the command line by passing in --procs.

Query the module index


source

NbdevLookup

 NbdevLookup (strip_libs=None, incl_libs=None, skip_mods=None)

Mapping from symbol names to docs and source URLs

Indexing returns a link to the symbol’s docs, along with the name of the source file the source URL if available.

c = NbdevLookup()
c['nbdev.doclinks.NbdevLookup']
('https://nbdev.fast.ai/api/doclinks.html#nbdevlookup',
 'nbdev/doclinks.py',
 'https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py')

source

NbdevLookup.doc

 NbdevLookup.doc (sym)

Link to docs for sym

c.doc('nbdev.doclinks.NbdevLookup')
'https://nbdev.fast.ai/api/doclinks.html#nbdevlookup'

Symbol names are taken from libraries registered using the ‘nbdev’ entry point. By default, all libraries with this entry point are searched, but full symbol names (including module prefix) are required.

assert c.doc('numpy.array').startswith('http')
assert c.doc('NbdevLookup').endswith('#nbdevlookup')
assert not c.doc('array')

Pass strip_libs to list libraries which should be available without requiring a module prefix.

c = NbdevLookup(strip_libs=('nbdev', 'nbdev_numpy'))
assert c.doc('array').startswith('http')

source

NbdevLookup.code

 NbdevLookup.code (sym)

Link to source code for sym

NbdevLookup().code('fastcore.net.urlsend')
'https://github.com/fastai/fastcore/blob/master/fastcore/net.py#LNone'

source

NbdevLookup.linkify

 NbdevLookup.linkify (md)
md = """This is a link to `numpy.array` and to `get_config` but not a link to `foobar`.
And not a link to <code>dict2nb</code>.

    This is not a link to `get_config`

```
This isn't a link to `get_config` either
```"""
print(NbdevLookup('nbdev').linkify(md))
This is a link to [`numpy.array`](https://numpy.org/doc/stable/reference/generated/numpy.array.html#numpy.array) and to [`get_config`](https://nbdev.fast.ai/api/config.html#get_config) but not a link to `foobar`.
And not a link to <code>dict2nb</code>.

    This is not a link to `get_config`

```
This isn't a link to `get_config` either
```