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

Linked notebooks with nblink (not working, as images and python download script wont be recognized) #332

Closed

Conversation

kolibril13
Copy link
Contributor

@kolibril13 kolibril13 commented Nov 5, 2021

No description provided.

@kolibril13
Copy link
Contributor Author

Seems there is a workaround here:
https://github.com/vidartf/nbsphinx-link
I will try this next

@kolibril13 kolibril13 mentioned this pull request Nov 5, 2021
@kolibril13
Copy link
Contributor Author

Another idea from here:
spatialaudio/nbsphinx#170 (comment)

print("Copy example notebooks into docs/_examples")

def all_but_ipynb(dir, contents):
    result = []
    for c in contents:
        if os.path.isfile(os.path.join(dir,c)) and (not c.endswith(".ipynb")):
            result += [c]
    return result


shutil.rmtree(os.path.join(project_root, "docs/_examples"), ignore_errors=True)
shutil.copytree(os.path.join(project_root, "examples"),
                os.path.join(project_root, "docs/_examples"),
                ignore=all_but_ipynb)

This is very hacky, but would most probably also work and would require less.nblinkfiles

@kolibril13
Copy link
Contributor Author

kolibril13 commented Nov 5, 2021

Another test with automated notebook link creation:

import json
from pathlib import Path

all_notebooks = !find Python/*.ipynb
for num, notebook in enumerate(all_notebooks):
    p=Path(notebook)
    names =  {"path": f"../../{p}"}
    print(names)
    base = Path('docs/source')
    jsonpath = base / (    p.stem + ".nblink")
    base.mkdir(exist_ok=True)
    jsonpath.write_text(json.dumps(names))

Edit:
But now the problem is, that images are not copied.

I found here another idea (spatialaudio/nbsphinx#170 (comment)):

My favorite option is indeed moving the notebooks to the docs/ folder and creating a symbolic link back to wherever else they should appear.

... but then the test might fail again, and symbolic links are also not the best solution.

@kolibril13 kolibril13 changed the title Link to the python notebooks with include syntax Linked notebooks with nblink (not working, as images and python download script wont be recognized) Nov 9, 2021
@kolibril13 kolibril13 marked this pull request as draft November 9, 2021 19:47
@kolibril13 kolibril13 closed this Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant