File tree Expand file tree Collapse file tree 10 files changed +119
-12
lines changed
Expand file tree Collapse file tree 10 files changed +119
-12
lines changed Original file line number Diff line number Diff line change 3333 run : |
3434 curl -L -s https://unpkg.com/wq > docs/js/wq.js
3535 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
3638 sed -i "s/^import\(.*\)https:\/\/unpkg.com\/wq/import\1.\/wq.js/" docs/js/*.js
3739 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
3846 - name : Build with Jekyll
3947 uses : actions/jekyll-build-pages@v1
4048 with :
Original file line number Diff line number Diff line change 55build
66dist
77node_modules
8+ docs /static
9+ docs /timeseries. *
Original file line number Diff line number Diff line change 1313 margin-right : auto;
1414 max-width : 100% ;
1515 }
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+ }
1625 </ style >
1726 < script async src ="https://www.googletagmanager.com/gtag/js?id=G-LTN8HFGJT2 "> </ script >
1827 < script >
Original file line number Diff line number Diff line change @@ -16,6 +16,20 @@ wq_config:
1616
1717[ ** Django REST Pandas on GitHub** ] ( https://github.com/wq/django-rest-pandas )
1818
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+
1933[ pandas ] : https://pandas.pydata.org/
2034[ Django REST Framework ] : https://www.django-rest-framework.org/
2135[ formats ] : ./renderers/index.md
Original file line number Diff line number Diff line change @@ -3,15 +3,21 @@ layout: null
33-- -
44
55import 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' ;
710
811const React = modules [ 'react' ] ;
912const { Typography, Link } = modules [ '@wq/material' ] ;
1013
11- wq . use ( markdown ) ;
14+ components . code = Demo ;
15+
16+ wq . use ( [ markdown , analyst ] ) ;
1217
1318const config = {
1419 site_title : 'Django REST Pandas' ,
20+ logo : '/images/icons/django-rest-pandas.svg' ,
1521 store : {
1622 service : '' ,
1723 defaults : {
@@ -52,6 +58,7 @@ function pageConf(page) {
5258 icon : page . wq_config . icon_data ? page . wq_config . name : null ,
5359 markdown : page . content ,
5460 list : true ,
61+ form : [ ] ,
5562 cache : 'all' ,
5663 can_change : false ,
5764 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 33< html lang ="en-us " dir ="ltr ">
44< head >
55< title > Multi Time Series</ title >
6- < link rel ="stylesheet " href ="admin/css/base.css ">
6+ < link rel ="stylesheet " href ="/static/ admin/css/base.css ">
77
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 >
1010
1111
1212
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 ">
1414
1515
1616
1717
1818 < 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 ">
2020
2121
2222< meta name ="robots " content ="NONE,NOARCHIVE ">
Original file line number Diff line number Diff line change 33< html lang ="en-us " dir ="ltr ">
44< head >
55< title > Time Series Custom</ title >
6- < link rel ="stylesheet " href ="admin/css/base.css ">
6+ < link rel ="stylesheet " href ="/static/ admin/css/base.css ">
77
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 >
1010
1111
1212
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 ">
1414
1515
1616
1717
1818 < 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 ">
2020
2121
2222< 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 55 "django.contrib.contenttypes" ,
66 "django.contrib.messages" ,
77 "django.contrib.sessions" ,
8+ "django.contrib.staticfiles" ,
89 "tests.testapp" ,
910 "rest_pandas" ,
1011 "rest_framework" ,
1617 }
1718}
1819ROOT_URLCONF = "tests.urls"
20+ STATIC_URL = "/static"
21+ STATIC_ROOT = "docs/static"
1922TEMPLATES = [
2023 {
2124 "BACKEND" : "django.template.backends.django.DjangoTemplates" ,
You can’t perform that action at this time.
0 commit comments