-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
116 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
build | ||
dist | ||
node_modules | ||
docs/static | ||
docs/timeseries.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { modules } from "https://unpkg.com/wq"; | ||
import { components } from "https://unpkg.com/@wq/markdown"; | ||
import { Analyst } from "https://unpkg.com/@wq/analyst"; | ||
|
||
const React = modules.react; | ||
const Code = components.code; | ||
|
||
export default function CodeDetect(props) { | ||
const { children: value } = props; | ||
if (value.includes("// @wq/analyst")) { | ||
const config = parseConfig(value); | ||
if (config) { | ||
return React.createElement(Analyst, { config }); | ||
} else { | ||
return React.createElement(Code, { | ||
children: "// Error parsing @wq/analyst config\n\n" + value, | ||
}); | ||
} | ||
} else { | ||
return React.createElement(Code, props); | ||
} | ||
} | ||
|
||
function parseConfig(value) { | ||
value = value.replace("// @wq/analyst", "").trim(); | ||
try { | ||
return JSON.parse(value); | ||
} catch { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters