Add documentation and fix paths (#14948)

* use posix relative path

* add doc link in dialog

* rename book to Jupyter book
This commit is contained in:
Barbara Valdez
2021-04-02 15:44:25 -07:00
committed by GitHub
parent 0d3112ef35
commit fde5caa9a4
5 changed files with 60 additions and 46 deletions

View File

@@ -10,10 +10,16 @@ export class TocEntryPathHandler {
public readonly fileInTocEntry: string;
public readonly titleInTocEntry: string;
public readonly fileExtension: FileExtension;
/**
* Creates an object that contains the specific format for title and file entries in a Jupyter Book table of contents
* that is compatible on Windows and Mac.
*/
constructor(public readonly filePath: string, public readonly bookRoot: string, title?: string) {
const relativePath = path.relative(bookRoot, filePath);
const pathDetails = path.parse(relativePath);
this.fileInTocEntry = relativePath.replace(pathDetails.ext, '');
//To keep consistency how the file entries are in Jupyter Book toc on Windows and Mac.
const tocRelativePath = path.posix.join(path.posix.sep, path.posix.relative(bookRoot, filePath));
const pathDetails = path.parse(tocRelativePath);
this.fileInTocEntry = tocRelativePath.replace(pathDetails.ext, '');
this.titleInTocEntry = title ?? pathDetails.name;
this.fileExtension = pathDetails.ext === FileExtension.Notebook ? FileExtension.Notebook : FileExtension.Markdown;
}