Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

use extension context for notebook search #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

laurajjiang
Copy link
Contributor

This PR fixes #37 - updates what the notebook and Jupyter book extensions using extension.contextPath to find files.


// Each notebook or markdown file packaged with your extension will be found through this
// function so that they can be individually opened through the `showNotebookDocument` command.
const extractNotebooksFromFolder = (fullFolderPath: string, notebookNames: Array<string>) => {
const extractNotebooksFromFolder = (fullFolderPath: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a return type to the method signature :string[]

@@ -65,7 +35,7 @@ const getFolderContent = (folderPath: string) => {
// to occur when you launch the book, add to the activate function.
export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.commands.registerCommand('launchNotebooks.<%= name %>', () => {
let notebooksToDisplay: Array<string> = processNotebooks();
let notebooksToDisplay: Array<string> = extractNotebooksFromFolder(context.extensionPath);
notebooksToDisplay.forEach(name => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upon extension activation, this will open all the notebooks? sounds scary 😨


// Each notebook or markdown file packaged with your extension will be found through this
// function so that they can be individually opened through the `showNotebookDocument` command.
const extractNotebooksFromFolder = (fullFolderPath: string, notebookNames: Array<string>) => {
const extractNotebooksFromFolder = (fullFolderPath: string) => {
let notebookNames: Array<string> = [];
const files = getFolderContent(fullFolderPath);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i read this correctly, you only handle the files in the top level folder without recursively going to the sub folders, by design?

Copy link
Collaborator

@alanrenmsft alanrenmsft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes themselves looks good to me, but I left some questions for the code that were not changed by this PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extension path in Jupyter Book extension should use context.extensionPath
2 participants