From 9f951dd2a5efd5fe81615b08e39b06db3f03cc62 Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Sun, 24 Mar 2024 22:12:46 +0000 Subject: [PATCH] Transition to the src layout --- docs/changelog.md | 7 +++++++ docs/custom_extensions.md | 18 +++++++++++++----- {itables => packages}/dt_for_itables/LICENSE | 0 {itables => packages}/dt_for_itables/README.md | 2 +- .../dt_for_itables/package-lock.json | 0 .../dt_for_itables/package.json | 4 +++- .../dt_for_itables/src/index.js | 0 pyproject.toml | 10 +++++----- {itables => src/itables}/__init__.py | 0 {itables => src/itables}/datatables_format.py | 0 {itables => src/itables}/downsample.py | 0 .../html/column_filters/initComplete.js | 0 .../html/column_filters/pre_dt_code.js | 0 .../itables}/html/datatables_template.html | 0 .../itables}/html/init_datatables.html | 0 {itables => src/itables}/interactive.py | 0 {itables => src/itables}/javascript.py | 0 {itables => src/itables}/options.py | 0 {itables => src/itables}/sample_dfs.py | 0 {itables => src/itables}/samples/countries.csv | 0 .../itables}/samples/indicators.csv | 0 .../itables}/samples/population.csv | 0 {itables => src/itables}/shiny.py | 0 {itables => src/itables}/utils.py | 0 {itables => src/itables}/version.py | 2 +- tests/test_update_samples.py | 2 +- 26 files changed, 31 insertions(+), 14 deletions(-) rename {itables => packages}/dt_for_itables/LICENSE (100%) rename {itables => packages}/dt_for_itables/README.md (97%) rename {itables => packages}/dt_for_itables/package-lock.json (100%) rename {itables => packages}/dt_for_itables/package.json (79%) rename itables/dt_for_itables/src.js => packages/dt_for_itables/src/index.js (100%) rename {itables => src/itables}/__init__.py (100%) rename {itables => src/itables}/datatables_format.py (100%) rename {itables => src/itables}/downsample.py (100%) rename {itables => src/itables}/html/column_filters/initComplete.js (100%) rename {itables => src/itables}/html/column_filters/pre_dt_code.js (100%) rename {itables => src/itables}/html/datatables_template.html (100%) rename {itables => src/itables}/html/init_datatables.html (100%) rename {itables => src/itables}/interactive.py (100%) rename {itables => src/itables}/javascript.py (100%) rename {itables => src/itables}/options.py (100%) rename {itables => src/itables}/sample_dfs.py (100%) rename {itables => src/itables}/samples/countries.csv (100%) rename {itables => src/itables}/samples/indicators.csv (100%) rename {itables => src/itables}/samples/population.csv (100%) rename {itables => src/itables}/shiny.py (100%) rename {itables => src/itables}/utils.py (100%) rename {itables => src/itables}/version.py (54%) diff --git a/docs/changelog.md b/docs/changelog.md index ad1a3ec5..35294596 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,6 +1,13 @@ ITables ChangeLog ================= +2.1.0-dev (2024-03-??) +------------------ + +**Changed** +- ITables now uses the `src` layout ([#246](https://github.com/mwouts/itables/issues/246)) - many thanks to [Mahendra Paipuri](https://github.com/mahendrapaipuri) for his help on this topic! + + 2.0.1 (2024-04-30) ------------------ diff --git a/docs/custom_extensions.md b/docs/custom_extensions.md index 9b450c30..5de5effe 100644 --- a/docs/custom_extensions.md +++ b/docs/custom_extensions.md @@ -53,18 +53,26 @@ To use custom extensions in the offline mode, you will need to create a bundle of jQuery, DataTables, and the desired extensions. To do so, make a copy of -[`itables/dt_for_itables`](https://github.com/mwouts/itables/tree/main/itables/dt_for_itables): +[`packages/dt_for_itables`](https://github.com/mwouts/itables/tree/main/packages/dt_for_itables): ```bash -$ ls itables/dt_for_itables/ -package.json package-lock.json README.md src.js +$ tree +``` +``` +. +├── LICENSE +├── package.json +├── package-lock.json +├── README.md +└── src + └── index.js ``` -Add or remove the desired extensions in `package.json` and `src.js`. To do this, +Add or remove the desired extensions in `package.json` and `src/index.js`. To do this, you can use the [DataTables download](https://datatables.net/download/) page and follow the instructions for the _NPM_ download method. For instance, say you want to bundle the PDF export button. Change -`src.js` to this code: +`src/index.js` to this code: ```javascript import JSZip from 'jszip'; import jQuery from 'jquery'; diff --git a/itables/dt_for_itables/LICENSE b/packages/dt_for_itables/LICENSE similarity index 100% rename from itables/dt_for_itables/LICENSE rename to packages/dt_for_itables/LICENSE diff --git a/itables/dt_for_itables/README.md b/packages/dt_for_itables/README.md similarity index 97% rename from itables/dt_for_itables/README.md rename to packages/dt_for_itables/README.md index 5b7bd4d4..8af8aa40 100644 --- a/itables/dt_for_itables/README.md +++ b/packages/dt_for_itables/README.md @@ -8,7 +8,7 @@ and some of its extensions for [ITables](https://github.com/mwouts/itables/). Run the following commands: ```bash npm install -npm run build +npm run build:js ``` # How to update the dependencies diff --git a/itables/dt_for_itables/package-lock.json b/packages/dt_for_itables/package-lock.json similarity index 100% rename from itables/dt_for_itables/package-lock.json rename to packages/dt_for_itables/package-lock.json diff --git a/itables/dt_for_itables/package.json b/packages/dt_for_itables/package.json similarity index 79% rename from itables/dt_for_itables/package.json rename to packages/dt_for_itables/package.json index 51d997be..85763b04 100644 --- a/itables/dt_for_itables/package.json +++ b/packages/dt_for_itables/package.json @@ -4,7 +4,9 @@ "description": "DataTables bundle for itables", "main": "src.js", "scripts": { - "build": "esbuild src.js --format=esm --bundle --outfile=dt_bundle.js --minify" + "build:js": "esbuild src/index.js --format=esm --bundle --outfile=dt_bundle.js --minify", + "install:js": "cp dt_bundle.js dt_bundle.css ../../src/itables/html", + "build": "npm run build:js && npm run install:js" }, "author": "Marc Wouts", "license": "MIT", diff --git a/itables/dt_for_itables/src.js b/packages/dt_for_itables/src/index.js similarity index 100% rename from itables/dt_for_itables/src.js rename to packages/dt_for_itables/src/index.js diff --git a/pyproject.toml b/pyproject.toml index b3530c4e..4b7203f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ test = [ ] [tool.hatch.version] -path = "itables/version.py" +path = "src/itables/version.py" [project.urls] Homepage = "https://mwouts.github.io/itables/" @@ -76,15 +76,15 @@ exclude_lines = [ enable-by-default = true dependencies = ["hatch-jupyter-builder"] build-function = "hatch_jupyter_builder.npm_builder" -ensured-targets = ["itables/dt_for_itables/dt_bundle.js", "itables/dt_for_itables/dt_bundle.css"] +ensured-targets = ["src/itables/html/dt_bundle.js", "src/itables/html/dt_bundle.css"] [tool.hatch.build.hooks.jupyter-builder.build-kwargs] -path = "itables/dt_for_itables" +path = "packages/dt_for_itables" build_cmd = "build" npm = ["npm"] [tool.hatch.build.targets.sdist] -artifacts = ["itables/dt_for_itables/dt_bundle.js", "itables/dt_for_itables/dt_bundle.css"] +artifacts = ["src/itables/html/dt_bundle.js", "src/itables/html/dt_bundle.css"] [tool.hatch.build.targets.wheel] -artifacts = ["itables/dt_for_itables/dt_bundle.js", "itables/dt_for_itables/dt_bundle.css"] +artifacts = ["src/itables/html/dt_bundle.js", "src/itables/html/dt_bundle.css"] diff --git a/itables/__init__.py b/src/itables/__init__.py similarity index 100% rename from itables/__init__.py rename to src/itables/__init__.py diff --git a/itables/datatables_format.py b/src/itables/datatables_format.py similarity index 100% rename from itables/datatables_format.py rename to src/itables/datatables_format.py diff --git a/itables/downsample.py b/src/itables/downsample.py similarity index 100% rename from itables/downsample.py rename to src/itables/downsample.py diff --git a/itables/html/column_filters/initComplete.js b/src/itables/html/column_filters/initComplete.js similarity index 100% rename from itables/html/column_filters/initComplete.js rename to src/itables/html/column_filters/initComplete.js diff --git a/itables/html/column_filters/pre_dt_code.js b/src/itables/html/column_filters/pre_dt_code.js similarity index 100% rename from itables/html/column_filters/pre_dt_code.js rename to src/itables/html/column_filters/pre_dt_code.js diff --git a/itables/html/datatables_template.html b/src/itables/html/datatables_template.html similarity index 100% rename from itables/html/datatables_template.html rename to src/itables/html/datatables_template.html diff --git a/itables/html/init_datatables.html b/src/itables/html/init_datatables.html similarity index 100% rename from itables/html/init_datatables.html rename to src/itables/html/init_datatables.html diff --git a/itables/interactive.py b/src/itables/interactive.py similarity index 100% rename from itables/interactive.py rename to src/itables/interactive.py diff --git a/itables/javascript.py b/src/itables/javascript.py similarity index 100% rename from itables/javascript.py rename to src/itables/javascript.py diff --git a/itables/options.py b/src/itables/options.py similarity index 100% rename from itables/options.py rename to src/itables/options.py diff --git a/itables/sample_dfs.py b/src/itables/sample_dfs.py similarity index 100% rename from itables/sample_dfs.py rename to src/itables/sample_dfs.py diff --git a/itables/samples/countries.csv b/src/itables/samples/countries.csv similarity index 100% rename from itables/samples/countries.csv rename to src/itables/samples/countries.csv diff --git a/itables/samples/indicators.csv b/src/itables/samples/indicators.csv similarity index 100% rename from itables/samples/indicators.csv rename to src/itables/samples/indicators.csv diff --git a/itables/samples/population.csv b/src/itables/samples/population.csv similarity index 100% rename from itables/samples/population.csv rename to src/itables/samples/population.csv diff --git a/itables/shiny.py b/src/itables/shiny.py similarity index 100% rename from itables/shiny.py rename to src/itables/shiny.py diff --git a/itables/utils.py b/src/itables/utils.py similarity index 100% rename from itables/utils.py rename to src/itables/utils.py diff --git a/itables/version.py b/src/itables/version.py similarity index 54% rename from itables/version.py rename to src/itables/version.py index 2104eec6..537a34c1 100644 --- a/itables/version.py +++ b/src/itables/version.py @@ -1,3 +1,3 @@ """ITables' version number""" -__version__ = "2.0.1" +__version__ = "2.1.0-dev" diff --git a/tests/test_update_samples.py b/tests/test_update_samples.py index f4b38cf2..7e2204f8 100644 --- a/tests/test_update_samples.py +++ b/tests/test_update_samples.py @@ -2,7 +2,7 @@ import world_bank_data as wb -SAMPLE_DIR = Path(__file__).parent / ".." / "itables" / "samples" +SAMPLE_DIR = Path(__file__).parent / ".." / "src" / "itables" / "samples" def create_csv_file_if_missing(df, csv_file):