Skip to content

Commit

Permalink
Transition to the src layout
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Mar 26, 2024
1 parent d45b5a1 commit 711b1af
Show file tree
Hide file tree
Showing 25 changed files with 33 additions and 16 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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 advice on this topic!


2.0.0 (2024-03-16)
------------------

Expand Down
20 changes: 14 additions & 6 deletions docs/custom_extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -97,7 +105,7 @@ npm install pdfmake --save
npm run build
```

Finally, you can either deploy `dt_bundle.js` and `dt_bundle.css` on an
Finally, you can either deploy `dt_bundle.js` and `dt_bundle.css` on a
http server and pass the URL of `dt_bundle.js` as the `dt_url` option to `show`,
or, in the offline mode, pass the path to `dt_bundle.js`
as the `dt_bundle` argument of the `init_notebook_mode` method (in either
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test = [
]

[tool.hatch.version]
path = "itables/version.py"
path = "src/itables/version.py"

[project.urls]
Homepage = "https://mwouts.github.io/itables/"
Expand All @@ -74,15 +74,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 = ["packages/dt_for_itables/dt_bundle.js", "packages/dt_for_itables/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"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion itables/options.py → src/itables/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
dt_url = UNPKG_DT_BUNDLE_URL

"""The DataTable bundle for the offline mode"""
dt_bundle = find_package_file("dt_for_itables/dt_bundle.js")
dt_bundle = find_package_file("html/dt_bundle.js")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion itables/version.py → src/itables/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""ITables' version number"""

__version__ = "2.0.0"
__version__ = "2.1.0-dev"
2 changes: 1 addition & 1 deletion tests/test_update_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 711b1af

Please sign in to comment.