Add abillity to open to specific item within a Jupyter book (#7155)

* Add abillity to open to specific item within a Jupyter book

* Move helper method into BookTreeItem class

* Fix default URL path

* Add typing to Jupyter book code

* Update comment and typings

* Fix compile error and cleanup
This commit is contained in:
Charles Gagnon
2019-09-13 11:51:15 -07:00
committed by GitHub
parent 3ac096b3b1
commit 888755e842
6 changed files with 133 additions and 47 deletions

View File

@@ -64,3 +64,55 @@ export type OutputType =
| 'stream'
| 'error'
| 'update_display_data';
export interface IJupyterBookToc {
sections: IJupyterBookSection[];
}
/**
* A section of a Jupyter book.
*
* This is taken from https://github.com/jupyter/jupyter-book/blob/master/jupyter_book/book_template/_data/toc.yml but is not
* enforced so invalid JSON may result in expected values being undefined.
*/
export interface IJupyterBookSection {
/**
* Title of chapter or section
*/
title?: string;
/**
* URL of section relative to the /content/ folder.
*/
url?: string;
/**
* Contains a list of more entries that make up the chapter's/section's sub-sections
*/
sections?: IJupyterBookSection[];
/**
* If the section shouldn't have a number in the sidebar
*/
not_numbered?: string;
/**
* If you'd like the sections of this chapter to always be expanded in the sidebar.
*/
expand_sections?: boolean;
/**
* Whether the URL is an external link or points to content in the book
*/
external?: boolean;
// Below are some special values that trigger specific behavior:
/**
* Will provide a link to a search page
*/
search?: boolean;
/**
* Will insert a divider in the sidebar
*/
divider?: boolean;
/**
* Will insert a header with no link in the sidebar
*/
header?: boolean;
}