jupyterlab / extension-examples

JupyterLab Extensions by Examples
BSD 3-Clause "New" or "Revised" License
454 stars 167 forks source link

Custom completer example #169

Closed ohrely closed 3 years ago

ohrely commented 3 years ago

Adds a basic example for customizing notebook completer functionality.

Inadvertently addresses https://github.com/jupyterlab/extension-examples/issues/156 by disabling the notebooks plugin.

ohrely commented 3 years ago

Some general comment, could you upgrade the example to use the latest cookiecutter template? You can achieve that thanks to scripts/upgrade_extensions.py

@fcollonval When I run this script, it makes modifications to setup.py and package.json in several of the example extensions and adds RELEASE.md to every extension. Is this the correct behavior?

fcollonval commented 3 years ago

Is this the correct behavior?

Yes this is expected as new commits have been pushed to the template project recently. If you can ignore those in the other extensions, it will be appreciated (so this PR keeps focusing on the new example alone).

ohrely commented 3 years ago

The two build_all tests are failing because one inserted code snippet is getting "corrected" by pre-commit linting, so it no longer matches the (more indented) source of the snippet. Is there a preferred way to address this?

I'm not sure what to make of the three failing build_extensions checks.

fcollonval commented 3 years ago

Thanks for pushing forward

To fix the linter error in the Readme, you should wrap the code snippets between special comments; e.g.

<!-- prettier-ignore-start -->
```ts // src/index.ts#L12-L14 

activate: (app: JupyterFrontEnd) => { 
console.log('the JupyterLab main application:', app); 
}, 
`` ` 
<!-- prettier-ignore-end -->

Regarding the remaining error in the new example, you need to overwrite tsconfig.json, .eslintrc.js, .eslintignore and .gitignore with those in the hello-world example (this is to ensure homogenous config).

hbcarlos commented 3 years ago

Hi @ohrely and @fcollonval, I rebased from master and added a basic test.

I'll update the extension to JupyterLab v3.1 too.

fcollonval commented 3 years ago

@hbcarlos thanks for pushing this one. Could you please add a more advanced ui test that open a notebook, trigger the completer and check the suggestions are the one expected?

hbcarlos commented 3 years ago

@fcollonval I'm not sure where the CI test fail. Do you have any advice?

fcollonval commented 3 years ago

We are getting closer 🙃

The integration test needs to be more robust. Did you try to run it locally before running it in the ci? Two ideas, the kernel may not be ready when you hit tab. So waiting for the idle state could be good. The other one is that I had some trouble with codemirror edition that I circumvent by using page.keyboard - see settings example.

hbcarlos commented 3 years ago

Thanks for the advice, @fcollonval! Yes, I tested locally before pushing to CI.

hbcarlos commented 3 years ago

Btw, when running locally, If you don't run npx playwright install first, the test fails because chromium is not installed.

fcollonval commented 3 years ago

Thanks @hbcarlos

I updated the test to trigger the custom completion and make it more robust. Plus I catched some missing package not listed in dependencies.

hbcarlos commented 3 years ago

Thanks to you for all the help!!

ohrely commented 3 years ago

Thank you both!