-
Notifications
You must be signed in to change notification settings - Fork 7
Docs external toc #122
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
Merged
Merged
Docs external toc #122
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c12b41c
Update update_env.md
Tom-van-Woudenberg fd5745d
Create external_toc.md
Tom-van-Woudenberg ca24038
Update Nested-Books
Tom-van-Woudenberg 48b1789
Merge branch 'release' into reorder_teachbooks
Tom-van-Woudenberg 988953f
Merge branch 'reorder_teachbooks' into docs_external_toc
Tom-van-Woudenberg 1aa6c8d
Move submodules to subpages as deprecated
Tom-van-Woudenberg 3d1fe40
Add explanation
Tom-van-Woudenberg 26d1d78
Update _toc.yml
Tom-van-Woudenberg a3131c2
Add functionalities
Tom-van-Woudenberg f361a63
Update external_toc.md
Tom-van-Woudenberg b82e6b9
Update book/features/external_toc.md
Tom-van-Woudenberg 36aafe5
Update book/features/external_toc.md
Tom-van-Woudenberg 93b74fd
Update book/features/external_toc.md
Tom-van-Woudenberg bd141d0
clarify teachbooks package button and improve general explanation
rlanzafame e86e597
pip install teachbooks>=0.2.0
rlanzafame 65687a3
simplify submodules part and clarify not in workflow
rlanzafame 857dbd5
Mention explicitly missing features
Tom-van-Woudenberg 271b492
Merge branch 'release' into docs_external_toc
Tom-van-Woudenberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,75 @@ | ||
(external-toc)= | ||
# Sharing content between books in table of contents | ||
|
||
```{admonition} User types | ||
:class: tip | ||
This page is useful for user type 3-5. | ||
``` | ||
|
||
{bdg-secondary}`Python Package: teachbooks` | ||
|
||
## Introduction | ||
|
||
When creating books, you might want to reuse material from other people or from other books you made. In some cases you might even want to have the exact same material into your book. You could do so by manually copying material over. However, whenever the source material is updated, you have to do that again. As an alternative, you can use the underlying git system to refer to the source file directly. This allows you to pick a specific version, or keep the most up-to-date version of it. This pages explains how to do so directly in the table of contents using the **External Content** (or **External TOC**) feature which is part of the TeachBooks Python package. | ||
|
||
Previously, this book feature was implemented using [submodules](../external/Nested-Books/README.md), but the implementation was more difficult to use. Despite this, submodules are still a widely used Git feature that can be very useful for book authors, so check out the [submodules page](../external/Nested-Books/README.md) to learn more, especially if the External TOC tool does not satisfy your needs. Submodules have a few additional features not (yet) implemented using the External TOC. | ||
|
||
```{warning} | ||
The External TOC features are not incorporated in the new deploy book workflow yet (this will happen once the workflow specifies `teachbooks>=0.2.0`). | ||
``` | ||
|
||
## What does it do? | ||
|
||
This functionality, part of the [TeachBooks package](https://github.com/TeachBooks/TeachBooks) allows you to refer to `.ipynb`, `.md` and `.rst` files stored on public repositories. These files are then handles as if they were normal files in your book, leading to a the file as a page in your built book. To prevent issues it validates that the external content has a permissive license, automatically combines any `reference.bib` files, and warns you if there's a mismatch in `requirements.txt` or with plugins in `_config.yml`. | ||
|
||
## Installation | ||
To use this extenstion, follow these steps: | ||
|
||
**Step 1: Install the Package** | ||
|
||
Install the module `teachbooks` package using `pip`: | ||
``` | ||
pip install teachbooks>=0.2.0 | ||
``` | ||
|
||
**Step 2: Add to `requirements.txt`** | ||
rlanzafame marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Make sure that the package is included in your project's `requirements.txt` to track the dependency: | ||
``` | ||
teachbooks>=0.2.0 | ||
``` | ||
|
||
## Usage | ||
|
||
To use the functionality, take the URL of a file and add it to your `_toc.yml` as follows: | ||
|
||
```yaml | ||
format: jb-book | ||
root: . | ||
|
||
parts: | ||
- caption: ... | ||
chapters: | ||
- file: ... | ||
. | ||
. | ||
. | ||
- external: <link to GitHub / GitLab source .md or .ipynb file> | ||
. | ||
. | ||
. | ||
``` | ||
|
||
The link can be pointing to a file on a branch (which will take the most recent version of that file on the branch) or a commit or tag (which will take a specific version of the file). For example: | ||
- `external: https://github.com/TeachBooks/manual/blob/release/book/intro.md` will take the most recent version of the intro page of this book on the release branch | ||
- `external: https://github.com/TeachBooks/manual/blob/06d67e8a0110c94d9147ce07090656dedc7d0e64/README.md` will take the file during the state of a specific commit (06d67e8). | ||
- `external: https://github.com/TeachBooks/manual/blob/v1.1.1/README.md` will take the file during the state of a specific tag (v1.1.1) | ||
|
||
If you're building your book online in GitHub, the [deploy-book-workflow](../external/deploy-book-workflow/README.md) will deal with these files during the `teachbooks build` command. If you want to build the book locally, run the command `teachbooks build`. | ||
|
||
If the source file is from another book, the contents of the `requirements.txt`, `_config.yml` are checked for any missing/incompatible entries. If this leads to compatibility issue, you'll be warned during the build which will help you solve these dependencies or plugins manually by updating your main book's `_config.yml` and `requirements.txt` | ||
Additionally, any `references.bib` files are merged into your main book's `references.bib` file, and the licenses of the external content are validated to allow for re-use. External content without a permissive license will result in an error to try to prevent any accidental copyright infringement. | ||
|
||
## Contribute | ||
|
||
This tool's repository is stored on [GitHub](https://github.com/TeachBooks/TeachBooks). If you'd like to contribute, you can create a fork and open a pull request on the [GitHub repository](https://github.com/TeachBooks/TeachBooks). |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be updated once the deploy book workflow uses
teachbooks>=0.2.0
.@Tom-van-Woudenberg do you just test this by running it in a fork a few times?
I made an Issue here #130
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rlanzafame, I don't understand what you mean? As soon as the external_toc thing is in main of taechbooks let's just directly publish it to a new version. After that, the deploy book workflow will make use of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not so simple:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know all of that and I think we argee that we shouldn't publish it as long as it affects the previous behaviour. But there's no change in behaviour as long as there's no
external:
in the toc right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. At least for the use case of GitHub Actions!