From d6cd1d4a323d0f0215c07c3aca8e5624a93c5f30 Mon Sep 17 00:00:00 2001 From: "S. Andrew Sheppard" Date: Mon, 1 Apr 2024 21:33:05 -0400 Subject: [PATCH] include @wq/analyst in docs --- .github/workflows/pages.yml | 8 ++++++++ .gitignore | 2 ++ docs/_layouts/default.html | 9 +++++++++ docs/index.md | 14 ++++++++++++++ docs/js/$index.js | 7 ++++++- docs/js/demo.js | 31 ++++++++++++++++++++++++++++++ tests/files/multitimeseries.html | 10 +++++----- tests/files/timeseries.html | 10 +++++----- tests/generate_docs.py | 33 ++++++++++++++++++++++++++++++++ tests/settings.py | 3 +++ 10 files changed, 116 insertions(+), 11 deletions(-) create mode 100644 docs/js/demo.js create mode 100644 tests/generate_docs.py diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 86a0de7..25d93fc 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -33,8 +33,16 @@ jobs: run: | curl -L -s https://unpkg.com/wq > docs/js/wq.js curl -L -s https://unpkg.com/@wq/markdown@latest > docs/js/markdown.js + curl -L -s https://unpkg.com/@wq/analyst@next > docs/js/analyst.js + curl -L -s https://unpkg.com/@wq/chart@next > docs/js/chart.js sed -i "s/^import\(.*\)https:\/\/unpkg.com\/wq/import\1.\/wq.js/" docs/js/*.js sed -i "s/^import\(.*\)https:\/\/unpkg.com\/@wq\/markdown@next/import\1.\/markdown.js/" docs/js/*.js + sed -i "s/^import\(.*\)https:\/\/unpkg.com\/@wq\/analyst/import\1.\/analyst.js/" docs/js/*.js + sed -i "s/^import\(.*\)https:\/\/unpkg.com\/@wq\/chart/import\1.\/chart.js/" docs/js/*.js + - name: Export Django site + run: | + python -m pip install django djangorestframework pandas + python -m unittest tests.generate_docs - name: Build with Jekyll uses: actions/jekyll-build-pages@v1 with: diff --git a/.gitignore b/.gitignore index 74bde4b..19d5b36 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ build dist node_modules +docs/static +docs/timeseries.* diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index ed4a06a..cefab5f 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -13,6 +13,15 @@ margin-right: auto; max-width: 100%; } + .MuiAppBar-colorPrimary img { + border-radius: 4px; + padding-left: 4px; + padding-right: 4px; + margin-left: -18px !important; + margin-top: 4px; + margin-bottom: 4px; + background-color: rgba(0, 0, 0, 0.6); + } + + - + - + diff --git a/tests/files/timeseries.html b/tests/files/timeseries.html index cdaed18..bd9dbfc 100644 --- a/tests/files/timeseries.html +++ b/tests/files/timeseries.html @@ -3,20 +3,20 @@ Time Series Custom - + - - + + - + - + diff --git a/tests/generate_docs.py b/tests/generate_docs.py new file mode 100644 index 0000000..b0f6d09 --- /dev/null +++ b/tests/generate_docs.py @@ -0,0 +1,33 @@ +import unittest +from rest_framework.test import APITestCase +from tests.testapp.models import TimeSeries, CustomIndexSeries +from django.core.management import call_command +import pathlib + + +DOCS = pathlib.Path("docs") + +class DocsTestCase(APITestCase): + def setUp(self): + data = ( + ("2014-01-01", 0.5), + ("2014-01-02", 0.4), + ("2014-01-03", 0.6), + ("2014-01-04", 0.2), + ("2014-01-05", 0.1), + ) + for date, value in data: + TimeSeries.objects.create(date=date, value=value) + + def test_docs(self): + call_command('collectstatic', interactive=False) + for url in ( + "timeseries.html", + "timeseries.csv", + "timeseries.json", + "timeseries.xlsx", + ): + response = self.client.get(f"/{url}") + path = DOCS / url + path.parent.mkdir(parents=True, exist_ok=True) + path.write_bytes(response.content) diff --git a/tests/settings.py b/tests/settings.py index cc993ed..68d260b 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -5,6 +5,7 @@ "django.contrib.contenttypes", "django.contrib.messages", "django.contrib.sessions", + "django.contrib.staticfiles", "tests.testapp", "rest_pandas", "rest_framework", @@ -16,6 +17,8 @@ } } ROOT_URLCONF = "tests.urls" +STATIC_URL = "/static" +STATIC_ROOT = "docs/static" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates",