File tree 10 files changed +119
-12
lines changed
10 files changed +119
-12
lines changed Original file line number Diff line number Diff line change 33
33
run : |
34
34
curl -L -s https://unpkg.com/wq > docs/js/wq.js
35
35
curl -L -s https://unpkg.com/@wq/markdown@latest > docs/js/markdown.js
36
+ curl -L -s https://unpkg.com/@wq/analyst@next > docs/js/analyst.js
37
+ curl -L -s https://unpkg.com/@wq/chart@next > docs/js/chart.js
36
38
sed -i "s/^import\(.*\)https:\/\/unpkg.com\/wq/import\1.\/wq.js/" docs/js/*.js
37
39
sed -i "s/^import\(.*\)https:\/\/unpkg.com\/@wq\/markdown@next/import\1.\/markdown.js/" docs/js/*.js
40
+ sed -i "s/^import\(.*\)https:\/\/unpkg.com\/@wq\/analyst/import\1.\/analyst.js/" docs/js/*.js
41
+ sed -i "s/^import\(.*\)https:\/\/unpkg.com\/@wq\/chart/import\1.\/chart.js/" docs/js/*.js
42
+ - name : Export Django site
43
+ run : |
44
+ python -m pip install django djangorestframework pandas openpyxl
45
+ python -m unittest tests.generate_docs
38
46
- name : Build with Jekyll
39
47
uses : actions/jekyll-build-pages@v1
40
48
with :
Original file line number Diff line number Diff line change 5
5
build
6
6
dist
7
7
node_modules
8
+ docs /static
9
+ docs /timeseries. *
Original file line number Diff line number Diff line change 13
13
margin-right : auto;
14
14
max-width : 100% ;
15
15
}
16
+ .MuiAppBar-colorPrimary img {
17
+ border-radius : 4px ;
18
+ padding-left : 4px ;
19
+ padding-right : 4px ;
20
+ margin-left : -18px !important ;
21
+ margin-top : 4px ;
22
+ margin-bottom : 4px ;
23
+ background-color : rgba (0 , 0 , 0 , 0.6 );
24
+ }
16
25
</ style >
17
26
< script async src ="https://www.googletagmanager.com/gtag/js?id=G-LTN8HFGJT2 "> </ script >
18
27
< script >
Original file line number Diff line number Diff line change @@ -16,6 +16,20 @@ wq_config:
16
16
17
17
[ ** Django REST Pandas on GitHub** ] ( https://github.com/wq/django-rest-pandas )
18
18
19
+ ## Live Demo
20
+
21
+ ``` js
22
+ // @wq/analyst
23
+ {
24
+ " url" : " /timeseries.csv" ,
25
+ " formats" : {
26
+ " csv" : " CSV" ,
27
+ " xlsx" : " Excel" ,
28
+ " json" : " JSON"
29
+ }
30
+ }
31
+ ```
32
+
19
33
[ pandas ] : https://pandas.pydata.org/
20
34
[ Django REST Framework ] : https://www.django-rest-framework.org/
21
35
[ formats ] : ./renderers/index.md
Original file line number Diff line number Diff line change @@ -3,15 +3,21 @@ layout: null
3
3
-- -
4
4
5
5
import wq , { modules } from 'https://unpkg.com/wq' ;
6
- import markdown , { renderers } from 'https://unpkg.com/@wq/markdown@next' ;
6
+ import markdown , { components } from 'https://unpkg.com/@wq/markdown@next' ;
7
+ import analyst from 'https://unpkg.com/@wq/analyst' ;
8
+
9
+ import Demo from './demo.js' ;
7
10
8
11
const React = modules [ 'react' ] ;
9
12
const { Typography, Link } = modules [ '@wq/material' ] ;
10
13
11
- wq . use ( markdown ) ;
14
+ components . code = Demo ;
15
+
16
+ wq . use ( [ markdown , analyst ] ) ;
12
17
13
18
const config = {
14
19
site_title : 'Django REST Pandas' ,
20
+ logo : '/images/icons/django-rest-pandas.svg' ,
15
21
store : {
16
22
service : '' ,
17
23
defaults : {
@@ -52,6 +58,7 @@ function pageConf(page) {
52
58
icon : page . wq_config . icon_data ? page . wq_config . name : null ,
53
59
markdown : page . content ,
54
60
list : true ,
61
+ form : [ ] ,
55
62
cache : 'all' ,
56
63
can_change : false ,
57
64
can_add : false ,
Original file line number Diff line number Diff line change
1
+ import { modules } from "https://unpkg.com/wq" ;
2
+ import { components } from "https://unpkg.com/@wq/markdown" ;
3
+ import { Analyst } from "https://unpkg.com/@wq/analyst" ;
4
+
5
+ const React = modules . react ;
6
+ const Code = components . code ;
7
+
8
+ export default function CodeDetect ( props ) {
9
+ const { children : value } = props ;
10
+ if ( value . includes ( "// @wq/analyst" ) ) {
11
+ const config = parseConfig ( value ) ;
12
+ if ( config ) {
13
+ return React . createElement ( Analyst , config ) ;
14
+ } else {
15
+ return React . createElement ( Code , {
16
+ children : "// Error parsing @wq/analyst config\n\n" + value ,
17
+ } ) ;
18
+ }
19
+ } else {
20
+ return React . createElement ( Code , props ) ;
21
+ }
22
+ }
23
+
24
+ function parseConfig ( value ) {
25
+ value = value . replace ( "// @wq/analyst" , "" ) . trim ( ) ;
26
+ try {
27
+ return JSON . parse ( value ) ;
28
+ } catch {
29
+ return null ;
30
+ }
31
+ }
Original file line number Diff line number Diff line change 3
3
< html lang ="en-us " dir ="ltr ">
4
4
< head >
5
5
< title > Multi Time Series</ title >
6
- < link rel ="stylesheet " href ="admin/css/base.css ">
6
+ < link rel ="stylesheet " href ="/static/ admin/css/base.css ">
7
7
8
- < link rel ="stylesheet " href ="admin/css/dark_mode.css ">
9
- < script src ="admin/js/theme.js " defer > </ script >
8
+ < link rel ="stylesheet " href ="/static/ admin/css/dark_mode.css ">
9
+ < script src ="/static/ admin/js/theme.js " defer > </ script >
10
10
11
11
12
12
13
- < link rel ="stylesheet " type ="text/css " href ="admin/css/forms.css ">
13
+ < link rel ="stylesheet " type ="text/css " href ="/static/ admin/css/forms.css ">
14
14
15
15
16
16
17
17
18
18
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
19
- < link rel ="stylesheet " href ="admin/css/responsive.css ">
19
+ < link rel ="stylesheet " href ="/static/ admin/css/responsive.css ">
20
20
21
21
22
22
< meta name ="robots " content ="NONE,NOARCHIVE ">
Original file line number Diff line number Diff line change 3
3
< html lang ="en-us " dir ="ltr ">
4
4
< head >
5
5
< title > Time Series Custom</ title >
6
- < link rel ="stylesheet " href ="admin/css/base.css ">
6
+ < link rel ="stylesheet " href ="/static/ admin/css/base.css ">
7
7
8
- < link rel ="stylesheet " href ="admin/css/dark_mode.css ">
9
- < script src ="admin/js/theme.js " defer > </ script >
8
+ < link rel ="stylesheet " href ="/static/ admin/css/dark_mode.css ">
9
+ < script src ="/static/ admin/js/theme.js " defer > </ script >
10
10
11
11
12
12
13
- < link rel ="stylesheet " type ="text/css " href ="admin/css/forms.css ">
13
+ < link rel ="stylesheet " type ="text/css " href ="/static/ admin/css/forms.css ">
14
14
15
15
16
16
17
17
18
18
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
19
- < link rel ="stylesheet " href ="admin/css/responsive.css ">
19
+ < link rel ="stylesheet " href ="/static/ admin/css/responsive.css ">
20
20
21
21
22
22
< meta name ="robots " content ="NONE,NOARCHIVE ">
Original file line number Diff line number Diff line change
1
+ import unittest
2
+ from rest_framework .test import APITestCase
3
+ from tests .testapp .models import TimeSeries , CustomIndexSeries
4
+ from django .core .management import call_command
5
+ import pathlib
6
+
7
+
8
+ DOCS = pathlib .Path ("docs" )
9
+
10
+ class DocsTestCase (APITestCase ):
11
+ def setUp (self ):
12
+ data = (
13
+ ("2014-01-01" , 0.5 ),
14
+ ("2014-01-02" , 0.4 ),
15
+ ("2014-01-03" , 0.6 ),
16
+ ("2014-01-04" , 0.2 ),
17
+ ("2014-01-05" , 0.1 ),
18
+ )
19
+ for date , value in data :
20
+ TimeSeries .objects .create (date = date , value = value )
21
+
22
+ def test_docs (self ):
23
+ call_command ('collectstatic' , interactive = False )
24
+ for url in (
25
+ "timeseries.html" ,
26
+ "timeseries.csv" ,
27
+ "timeseries.json" ,
28
+ "timeseries.xlsx" ,
29
+ ):
30
+ response = self .client .get (f"/{ url } " )
31
+ path = DOCS / url
32
+ path .parent .mkdir (parents = True , exist_ok = True )
33
+ path .write_bytes (response .content )
Original file line number Diff line number Diff line change 5
5
"django.contrib.contenttypes" ,
6
6
"django.contrib.messages" ,
7
7
"django.contrib.sessions" ,
8
+ "django.contrib.staticfiles" ,
8
9
"tests.testapp" ,
9
10
"rest_pandas" ,
10
11
"rest_framework" ,
16
17
}
17
18
}
18
19
ROOT_URLCONF = "tests.urls"
20
+ STATIC_URL = "/static"
21
+ STATIC_ROOT = "docs/static"
19
22
TEMPLATES = [
20
23
{
21
24
"BACKEND" : "django.template.backends.django.DjangoTemplates" ,
You can’t perform that action at this time.
0 commit comments