Wykres commitów

34 Commity (main)

Autor SHA1 Wiadomość Data
Simon Willison 5c64af6936 Upgrade to latest Black, closes #2239 2024-01-30 19:55:26 -08:00
Simon Willison c3caf36af7
Template slot family of plugin hooks - top_homepage() and others
New plugin hooks:

top_homepage
top_database
top_table
top_row
top_query
top_canned_query

New datasette.utils.make_slot_function()

Closes #1191
2024-01-30 19:54:03 -08:00
Simon Willison a25bf6bea7 fmt: off to fix problem with Black, closes #2231 2024-01-10 14:12:20 -08:00
Simon Willison 7506a89be0 Docs on datasette.client for tests, closes #1830
Also covers ds.client.actor_cookie() helper
2024-01-10 13:04:34 -08:00
Simon Willison f6bf2d8045 Initial prototype of API explorer at /-/api, refs #1871 2022-10-29 23:20:11 -07:00
Simon Willison d9b508ffaa @documented decorator plus unit test plus sphinx.ext.autodoc
New mechanism for marking datasette.utils functions that should be covered by the
documentation, then testing that they have indeed been documented.

Also enabled sphinx.ext.autodoc which can now be used to embed the documented
versions of those functions.

Refs #1176
2022-02-06 22:31:06 -08:00
Simon Willison 3664ddd400 Replace update-docs-help.py with cog, closes #1598 2022-01-13 16:47:53 -08:00
Simon Willison a1f3830356 --cpu option for datasette publish cloudrun, closes #1420 2021-08-03 22:20:50 -07:00
Konstantin Baikov 8e18c79431
Use context manager instead of plain open (#1211)
Context manager with open closes the files after usage.

When the object is already a pathlib.Path i used read_text
write_text functions

In some cases pathlib.Path.open were used in context manager,
it is basically the same as builtin open.

Thanks, Konstantin Baikov!
2021-03-11 08:15:49 -08:00
Miroslav Šedivý a882d67962
Modernize code to Python 3.6+ (#1158)
* Compact dict and set building
* Remove redundant parentheses
* Simplify chained conditions
* Change method name to lowercase
* Use triple double quotes for docstrings

Thanks, @eumiro!
2020-12-23 09:04:32 -08:00
Simon Willison 5a77f7a649 Updated docs renaming config to settings
- config.html is now settings.html
- ConfigOption in app.py is now Setting
- updated documentation unit tests

Refs #1106
2020-11-24 13:22:33 -08:00
Simon Willison 30e64c8d3b
Use f-strings in place of .format()
Code transformed like so:

    pip install flynt
    flynt .
    black .
2020-11-15 15:24:22 -08:00
Simon Willison 2da4144c57 Applied Black 2020-08-16 10:35:14 -07:00
Simon Willison ac69d151c3 Test that plugin hooks are documented with correct arguments 2020-08-16 10:33:44 -07:00
Simon Willison 751e7b4af7 Update tests for new plugin_hooks.rst, refs #687 2020-06-21 19:41:07 -07:00
Simon Willison 9f3d4aba31 --root option and /-/auth-token view, refs #784 2020-05-31 18:16:42 -07:00
Simon Willison cef23e8861 Started pattern portfolio at /-/patterns, refs #151 2020-05-02 20:05:25 -07:00
Simon Willison 25014ca25e
Configuration directory mode, closes #731 2020-04-27 09:30:24 -07:00
Simon Willison 5f4aeb1f19 Removed documentation for Zeit Now v1, refs #710 2020-03-24 15:45:24 -07:00
Simon Willison 7d8573d672 Rename "datasette publish now" to "datasette publish nowv1"
Also added an alias so "datasette publish now" continues to work.

Closes #472
2019-05-19 11:06:51 -07:00
Simon Willison 35d6ee2790
Apply black to everything, enforce via unit tests (#449)
I've run the black code formatting tool against everything:

    black tests datasette setup.py

I also added a new unit test, in tests/test_black.py, which will fail if the code does not
conform to black's exacting standards.

This unit test only runs on Python 3.6 or higher, because black itself doesn't run on 3.5.
2019-05-03 22:15:14 -04:00
Simon Willison bade9daeb2 Docs for 'datasette publish cloudrun', refs #434 2019-05-03 12:16:58 -04:00
Simon Willison 2c19a27d15 Documentation for filters, plus new documentation unit test
https://simonwillison.net/2018/Jul/28/documentation-unit-tests/
2019-04-15 15:41:11 -07:00
Simon Willison 0a14a4846b
Added plugin_config() method 2018-08-28 01:35:21 -07:00
Simon Willison 295d005ca4
Renamed variable, since docs are not written in Markdown 2018-07-27 21:56:51 -07:00
Simon Willison 8128497b79
Only run documented_views() fixture once per session
Speeds up tests, because previously it ran once per view class.
2018-07-27 21:49:20 -07:00
Simon Willison 788a542d3c
Docs for IndexView, TableView, RowView, closes #299
Also removed xfail from test_view_classes_are_documented, so any future *View
classes that are added without documentation will cause the tests to fail.
2018-07-27 21:21:42 -07:00
Simon Willison e8625695a3
xfail documentation unit tests for view classes, refs #299
More documentation unit tests. These ones check that every single **View class
imported into the datasette/app.py module are covered by our documentation.

Just one problem: they aren't documented yet. So I'm using the xfail pytest
decorator to mark these tests as allowed-to-fail. When you run the test suite
you now get a report of how many views still need to be documented, but it
doesn't fail the tests.

The output looks something like this:

    $ pytest tests/test_docs.py
    collected 31 items

    tests/test_docs.py ..........................XXXxx.                [100%]

    ============ 26 passed, 2 xfailed, 3 xpassed in 1.06 seconds ============

Once I have documented all the views I will remove the xfail so any future
views that are added without documentation will cause a test failure.

We can detect that a view is documented by looking for ReST label in the docs,
for example:

    .. _IndexView:

Some view classes can be used to power multiple URLs - the JsonDataView class
for example is used to power /-/metadata and /-/config and /-/plugins

In this case, the second part of the label can indicate the variety of page, e.g:

    .. _JsonDataView_metadata:

The test will pass as long as there is at least one label that starts with
_JsonDataView.
2018-07-27 20:13:26 -07:00
Simon Willison dbbe707841
publish_subcommand hook + default plugins mechanism, used for publish heroku/now (#349)
This change introduces a new plugin hook, publish_subcommand, which can be
used to implement new subcommands for the "datasette publish" command family.

I've used this new hook to refactor out the "publish now" and "publish heroku"
implementations into separate modules. I've also added unit tests for these
two publishers, mocking the subprocess.call and subprocess.check_output
functions.

As part of this, I introduced a mechanism for loading default plugins. These
are defined in the new "default_plugins" list inside datasette/app.py

Closes #217 (Plugin support for datasette publish)
Closes #348 (Unit tests for "datasette publish")
Refs #14, #59, #102, #103, #146, #236, #347
2018-07-25 22:15:59 -07:00
Simon Willison 3ac21c7498
Unit test confirming all plugin hooks are documented 2018-07-25 21:09:59 -07:00
Simon Willison ba64cfb4bc
Fix for Python 3.5
https://stackoverflow.com/a/42694113/6083
2018-07-25 10:20:56 -07:00
Simon Willison 9b85c59907
Removed unnecessary print statements from tests 2018-07-24 09:04:06 -07:00
Simon Willison 74ad3ff4af
Ensure --help examples in docs are always up to date, closes #336
Unit tests now check that docs/*.txt help examples are all up-to-date.

I ran into a problem here in that the terminal_width needed to be more
accurately defined - so I replaced update-docs-help.sh with update-docs-
help.py which hard-codes the terminal width.
2018-07-24 09:01:23 -07:00
Simon Willison a6afc21aba
Test that ensures all config options are documented 2018-05-26 15:11:16 -07:00