GithubHelp home page GithubHelp logo

quantstack / jupyterlab-snippets Goto Github PK

View Code? Open in Web Editor NEW
63.0 63.0 23.0 119 KB

Snippets Extension for JupyterLab

License: BSD 3-Clause "New" or "Revised" License

Python 41.60% TypeScript 30.36% JavaScript 12.28% Jupyter Notebook 5.38% Shell 10.23% CSS 0.15%

jupyterlab-snippets's People

Contributors

fcollonval avatar github-actions[bot] avatar jtpio avatar mariobuikhuizen avatar sylvaincorlay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jupyterlab-snippets's Issues

Skip hidden folder

When allowing modification in the folder within JupyterLab, the .ipynb_checkpoints folder is created along side the snippets. After restarting JLab, the checkpoint folder will be displayed in the snippets menus.

So it would be nice to ignore hidden folder.

image

add option to insert cell above the current cell

It would be nice to be able to control if the snippet is inserted above or below the current cell. For instance, when you open a new notebook and want to paste in an import cell it would be nice to have it be the very first cell.

possible solutions

  1. The extension uses the jupyterlab settings editor for this
  2. use comments in the snippets to add metadata. Something like:
# <snippet-metadata>
# placement = 'above'
# </snippet-metadata>

p.s.

A++ on this extension - it's much nicer than my hacky bash + xdotool + gnome keyboard shortcuts approach

Snippets or code snippets?

Since the extension can load arbitrary text file content, should this extension still be named "code snippets"? Or just "snippets"?

Conflicting Dependencies with jupyterlab 2.1.4

The command <jupyter labextension install @quentinandre/jupyterlab_snippets>
results in the following error message:
Conflicting Dependencies:
JupyterLab Extension Package

=2.1.2 <2.2.0 >=0.19.1 <0.20.0@jupyterlab/application
=2.1.1 <2.2.0 >=0.19.1 <0.20.0@jupyterlab/apputils
=4.1.0 <4.2.0 >=2.1.3 <3.0.0 @jupyterlab/coreutils
=2.1.2 <2.2.0 >=0.19.1 <0.20.0@jupyterlab/notebook

Have a message in the menu (or a dialog) if no snippets are found

If a user clicks on the snippets menu and there are no snippets perhaps a dialog could be raised that tells the user:

  1. What folder the extension is looking in
  2. That they should add .py files there
  3. That they will then need to refresh their browser

I think point 3 is particularly important as this may not be obvious

Allow assigning keyboard shortcuts to snippets

For snippets that are regularly used it would be great to access them via a keyboard shortcut rather than having to use the mouse. Perhaps shortcuts could be stored in a metadata comment at the top of the notebook?

Feature req: Vim-like tab functionality

Essentially each snipped could then have a short-name, where tab after that name expands the snippet. Repeated tab-presses then jumps you to the pre-defined places where input is needed, and a final tab puts you just outside the snippet end. One example
here and a more advanced example with auto-generated docstrings here.

Jupyter Cal Poly Interns

Hello!

@tgeorgeux and I have been considering having our @jupytercalpoly Intern team do some user research this summer around a snippet extension for JupyterLab. They'd focus on the design aspects, user experience, and user stories for this type of extension.

Depending on your plans for this extension, we'd love to collaborate with you. We can have a team of three students doing some design+prototyping full-time over the summer and (hopefully) contribute some useful work around this extension's user experience. Let me know what you think!

Release on conda

It would be great to have this package released on conda as well!

Add Binder with the default snippets

Having a Binder link would be really useful to give an idea of what it looks like.

Also we could use the default snippets to populate the menu.

Remove hidden files and python autogenerated bytecode cache files

When allowing modifications in the snippets folder within JupyterLab data path, __pycache__ folder may get created along side the snippets. This folder is getting listed in the snippets menu. Also, existing/auto-generated hidden files like .DS_STORE can be removed from getting listed in the snippets menu.

Screenshot 2023-06-27 at 3 23 20 PM

Add snippets to source files and consoles

For now snippets only work for notebooks, and a new cell is created when a snippet is chosen.

But it could actually be used for files and consoles too, by injecting the code snippet into the code editor at the current cursor location.

Compatibility with current Jupyter Lab

I recently did a clean install of Jupyter Lab so I have a stable setup, without all those startup warnings etc.

I am keen to again have a "snippets" capability.

However I am a bit reluctant to install this Quantstack/jupyterlab-snippets (at v0.4.1) due to the downgrades of jupyterlab and jupyter_client that this will entail. See conda install dialog below.

Are there plans to update this module to work with the newer versions of Jupyter Lab?

thanks

pwsh> conda install -c conda-forge jupyterlab-snippets

  added / updated specs:
    - jupyterlab-snippets

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ipython_genutils-0.2.0     |             py_1          21 KB  conda-forge
    jupyter_client-7.4.9       |     pyhd8ed1ab_0          97 KB  conda-forge
    jupyterlab-3.5.0           |     pyhd8ed1ab_0         6.0 MB  conda-forge
    jupyterlab-snippets-0.4.1  |     pyhd8ed1ab_0          19 KB  conda-forge
    jupyterlab_pygments-0.3.0  |     pyhd8ed1ab_0          18 KB  conda-forge
    nbclassic-1.0.0            |     pyhb4ecaf3_1         5.7 MB  conda-forge
    nbconvert-7.16.3           |       hd8ed1ab_0           8 KB  conda-forge
    nbconvert-pandoc-7.16.3    |       hd8ed1ab_0           7 KB  conda-forge
    notebook-6.5.6             |     pyha770c72_0         299 KB  conda-forge
    pandoc-3.1.12.3            |       h57928b3_0        23.7 MB  conda-forge
    pyzmq-24.0.1               |  py311h7b3f143_1         533 KB  conda-forge
    zeromq-4.3.4               |       h0e60522_1         8.9 MB  conda-forge
    ------------------------------------------------------------
                                           Total:        45.3 MB

The following NEW packages will be INSTALLED:

  ipython_genutils   conda-forge/noarch::ipython_genutils-0.2.0-py_1
  jupyterlab-snippe~ conda-forge/noarch::jupyterlab-snippets-0.4.1-pyhd8ed1ab_0
  nbclassic          conda-forge/noarch::nbclassic-1.0.0-pyhb4ecaf3_1
  nbconvert          conda-forge/noarch::nbconvert-7.16.3-hd8ed1ab_0
  nbconvert-pandoc   conda-forge/noarch::nbconvert-pandoc-7.16.3-hd8ed1ab_0
  notebook           conda-forge/noarch::notebook-6.5.6-pyha770c72_0
  pandoc             conda-forge/win-64::pandoc-3.1.12.3-h57928b3_0


The following packages will be DOWNGRADED:

  jupyter_client                         8.6.1-pyhd8ed1ab_0 --> 7.4.9-pyhd8ed1ab_0
  jupyterlab                             4.1.5-pyhd8ed1ab_0 --> 3.5.0-pyhd8ed1ab_0
  jupyterlab_pygmen~                     0.3.0-pyhd8ed1ab_1 --> 0.3.0-pyhd8ed1ab_0
  pyzmq                              25.1.2-py311h9250fbb_0 --> 24.0.1-py311h7b3f143_1
  zeromq                                   4.3.5-h63175ca_1 --> 4.3.4-h0e60522_1

Add tests

To test:

  • the API
  • the server extension is enabled
  • the JupyterLab extension can be built

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.