Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ module.exports = {
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'prefer-rest-params': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false }
],
'@typescript-eslint/no-this-alias': [
'error',
{ "allowDestructuring": true, "allowedNames": ["_this"] }
],
curly: ['error', 'all'],
eqeqeq: 'error',
'prefer-arrow-callback': 'error'
}
};
};
3 changes: 2 additions & 1 deletion css/widget.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.custom-widget {
background-color: blue;
background-color: lightseagreen;
padding: 0px 2px;
}
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -175,7 +175,7 @@
'widget_code_input Documentation',
author,
'widget_code_input',
'A Jupyter widget to allow input of a python function, with syntax highlighting.',
'A widget to allow input of a python function, with syntax highlighting.',
'Miscellaneous'),
]

Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ widget_code_input

Version: |release|

A Jupyter widget to allow input of a python function, with syntax highlighting.
A widget to allow input of a python function, with syntax highlighting.


Quickstart
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "widget-code-input",
"version": "3.0.0",
"description": "A Jupyter widget to allow input of a python function, with syntax highlighting.",
"version": "3.5.0",
"description": "A widget to allow input of a python function, with syntax highlighting.",
"keywords": [
"jupyter",
"jupyterlab",
Expand All @@ -19,7 +19,7 @@
},
"license": "BSD-3-Clause",
"author": {
"name": "Dou Du",
"name": "Dou Du and Giovanni Pizzi",
"email": "dou.du@epfl.ch"
},
"main": "lib/index.js",
Expand Down Expand Up @@ -49,15 +49,16 @@
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyter-widgets/base": "^1.1.10 || ^2.0.0 || ^3.0.0 || ^4.0.0",
"codemirror": "5.58.2"
"@jupyter-widgets/base": "^1.1.10 || ^2 || ^3 || ^4 || ^5 || ^6",
"codemirror": "5.65.9"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/preset-env": "^7.5.0",
"@jupyter-widgets/base-manager": "^1.0.2",
"@jupyterlab/builder": "^3.0.0",
"@phosphor/application": "^1.6.0",
"@phosphor/widgets": "^1.6.0",
"@lumino/application": "^1.6.0",
"@lumino/widgets": "^1.6.0",
"@types/jest": "^26.0.0",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^3.6.0",
Expand All @@ -79,7 +80,7 @@
"ts-jest": "^26.0.0",
"ts-loader": "^8.0.0",
"typescript": "~4.1.3",
"webpack": "^5.0.0",
"webpack": "^5.61.0",
"webpack-cli": "^4.0.0",
"underscore": "^1.13.2",
"@types/codemirror": "^0.0.76"
Expand Down
113 changes: 111 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,112 @@
[build-system]
requires = ["jupyter_packaging==0.7.9", "jupyterlab==3.*", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = [
"hatchling>=1.3.1",
"jupyterlab==3.*",
]
build-backend = "hatchling.build"

[project]
name = "widget_code_input"
description = "A widget to allow input of a python function, with syntax highlighting."
readme = "README.md"
license = { file = "LICENSE.txt" }
requires-python = ">=3.7"
authors = [
{ name = "Dou Du", email = "dou.du@epfl.ch" },
]
keywords = [
"IPython",
"Jupyter",
"Widgets",
]
classifiers = [
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
]
dependencies = [
"ipywidgets>=7.0.0",
]
version = "0.1.0.dev0"

[project.optional-dependencies]
docs = [
"jupyter_sphinx",
"nbsphinx",
"nbsphinx-link",
"pypandoc",
"pytest_check_links",
"recommonmark",
"sphinx>=1.5",
"sphinx_rtd_theme",
]
examples = []
test = [
"nbval",
"pytest-cov",
"pytest>=6.0",
]

[project.urls]
Homepage = "https://github.com/osscar-org/widget-code-input"

[tool.hatch.build]
artifacts = [
"widget_code_input/nbextension/index.*",
"widget_code_input/labextension/*.tgz",
"widget_code_input/labextension",
]

[tool.hatch.build.targets.wheel.shared-data]
"widget_code_input/nbextension" = "share/jupyter/nbextensions/widget_code_input"
"widget_code_input/labextension" = "share/jupyter/labextensions/widget_code_input"
"./install.json" = "share/jupyter/labextensions/widget_code_input/install.json"
"./widget_code_input.json" = "etc/jupyter/nbconfig/notebook.d/widget_code_input.json"

[tool.hatch.build.targets.sdist]
exclude = [
".github",
]

[tool.hatch.build.hooks.jupyter-builder]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"widget_code_input/nbextension/index.js",
"widget_code_input/labextension/package.json",
]
skip-if-exists = [
"widget_code_input/nbextension/index.js",
"widget_code_input/labextension/package.json",
]
dependencies = [
"hatch-jupyter-builder>=0.5.0",
]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
path = "."
build_cmd = "build:prod"

[tool.tbump]
field = [
{ name = "channel", default = "" },
{ name = "release", default = "" },
]
file = [
{ src = "pyproject.toml", version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\"" },
{ src = "widget_code_input/_version.py" },
]

[tool.tbump.version]
current = "0.1.0.dev0"
regex = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)((?P<channel>a|b|rc|.dev)(?P<release>\\d+))?"

[tool.tbump.git]
message_template = "Bump to {new_version}"
tag_template = "v{new_version}"
124 changes: 2 additions & 122 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,122 +1,2 @@
#!/usr/bin/env python
# coding: utf-8

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

from __future__ import print_function
from glob import glob
import os
from os.path import join as pjoin
from setuptools import setup, find_packages


from jupyter_packaging import (
create_cmdclass,
install_npm,
ensure_targets,
combine_commands,
get_version,
skip_if_exists
)

HERE = os.path.dirname(os.path.abspath(__file__))




# The name of the project
name = 'widget_code_input'

# Get the version
version = get_version(pjoin(name, '_version.py'))


# Representative files that should exist after a successful build
jstargets = [
pjoin(HERE, name, 'nbextension', 'index.js'),
pjoin(HERE, name, 'labextension', 'package.json'),
]


package_data_spec = {
name: [
'nbextension/**js*',
'labextension/**'
]
}


data_files_spec = [
('share/jupyter/nbextensions/widget_code_input', 'widget_code_input/nbextension', '**'),
('share/jupyter/labextensions/widget-code-input', 'widget_code_input/labextension', '**'),
('share/jupyter/labextensions/widget-code-input', '.', 'install.json'),
('etc/jupyter/nbconfig/notebook.d', '.', 'widget_code_input.json'),
]


cmdclass = create_cmdclass('jsdeps', package_data_spec=package_data_spec,
data_files_spec=data_files_spec)
npm_install = combine_commands(
install_npm(HERE, build_cmd='build:prod'),
ensure_targets(jstargets),
)
cmdclass['jsdeps'] = skip_if_exists(jstargets, npm_install)


setup_args = dict(
name = name,
description = 'A Jupyter widget to allow input of a python function, with syntax highlighting.',
version = version,
scripts = glob(pjoin('scripts', '*')),
cmdclass = cmdclass,
packages = find_packages(),
author = 'Dou Du',
author_email = 'dou.du@epfl.ch',
url = 'https://github.com/osscar-org/widget-code-input',
license = 'BSD',
platforms = "Linux, Mac OS X, Windows",
keywords = ['Jupyter', 'Widgets', 'IPython'],
classifiers = [
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Framework :: Jupyter',
],
include_package_data = True,
python_requires=">=3.6",
install_requires = [
'ipywidgets>=7.0.0',
],
extras_require = {
'test': [
'pytest>=4.6',
'pytest-cov',
'nbval',
],
'examples': [
# Any requirements for the examples to run
],
'docs': [
'jupyter_sphinx',
'nbsphinx',
'nbsphinx-link',
'pytest_check_links',
'pypandoc',
'recommonmark',
'sphinx>=1.5',
'sphinx_rtd_theme',
],
},
entry_points = {
},
)

if __name__ == '__main__':
setup(**setup_args)
# setup.py shim for use with applications that require it.
__import__("setuptools").setup()
12 changes: 6 additions & 6 deletions src/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

import { createTestModel } from './utils';

import { ExampleModel } from '..';
import { WidgetCodeModel } from '..';

describe('Example', () => {
describe('ExampleModel', () => {
describe('WidgetCodeModel', () => {
it('should be createable', () => {
const model = createTestModel(ExampleModel);
expect(model).toBeInstanceOf(ExampleModel);
const model = createTestModel(WidgetCodeModel);
expect(model).toBeInstanceOf(WidgetCodeModel);
expect(model.get('value')).toEqual('Hello World');
});

it('should be createable with a value', () => {
const state = { value: 'Foo Bar!' };
const model = createTestModel(ExampleModel, state);
expect(model).toBeInstanceOf(ExampleModel);
const model = createTestModel(WidgetCodeModel, state);
expect(model).toBeInstanceOf(WidgetCodeModel);
expect(model.get('value')).toEqual('Foo Bar!');
});
});
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Distributed under the terms of the Modified BSD License.

import * as widgets from '@jupyter-widgets/base';
import * as baseManager from '@jupyter-widgets/base-manager';
import * as services from '@jupyterlab/services';

let numComms = 0;
Expand Down Expand Up @@ -44,7 +45,7 @@ export class MockComm implements widgets.IClassicComm {
_on_close: ((x?: any) => void) | null = null;
}

export class DummyManager extends widgets.ManagerBase<HTMLElement> {
export class DummyManager extends baseManager.ManagerBase {
constructor() {
super();
this.el = window.document.createElement('div');
Expand Down
4 changes: 2 additions & 2 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Dou Du
// Distributed under the terms of the Modified BSD License.

import { Application, IPlugin } from '@phosphor/application';
import { Application, IPlugin } from '@lumino/application';

import { Widget } from '@phosphor/widgets';
import { Widget } from '@lumino/widgets';

import { IJupyterWidgetRegistry } from '@jupyter-widgets/base';

Expand Down
Loading