Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use svelte for the HTML renderer #222

Merged
merged 4 commits into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
with:
python-version: '3.8'

- name: Check manifest
run: pipx run check-manifest

- name: Build sdist
run: python setup.py sdist

Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ repos:
rev: v2.1.0
hooks:
- id: codespell
exclude: "\\.(json)$"
args:
- --ignore-words-list=vas --skip="*.js"
- --ignore-words-list=vas

- repo: local
hooks:
Expand Down
15 changes: 10 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
include README.md
include LICENSE
recursive-include pyinstrument *.js
recursive-include html_renderer *.html *.json *.js *.ts *.vue *.css *.png
prune **

graft pyinstrument
graft test
graft bin
graft html_renderer
prune html_renderer/node_modules
prune html_renderer/dist
include pyinstrument/py.typed

include LICENSE README.md pyproject.toml setup.py setup.cfg noxfile.py requirements-dev.txt

global-exclude __pycache__ *.py[cod] .* dist
4 changes: 3 additions & 1 deletion bin/build_js_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

HTML_RENDERER_DIR = "html_renderer"
JS_BUNDLE = "pyinstrument/renderers/html_resources/app.js"
CSS_BUNDLE = "pyinstrument/renderers/html_resources/app.css"

if __name__ == "__main__":
# chdir to root of repo
Expand Down Expand Up @@ -42,4 +43,5 @@
subprocess.check_call("npm ci", cwd=HTML_RENDERER_DIR, shell=True)
subprocess.check_call("npm run build", cwd=HTML_RENDERER_DIR, shell=True)

shutil.copyfile(HTML_RENDERER_DIR + "/dist/js/app.js", JS_BUNDLE)
shutil.copyfile(HTML_RENDERER_DIR + "/dist/pyinstrument-html.iife.js", JS_BUNDLE)
shutil.copyfile(HTML_RENDERER_DIR + "/dist/style.css", CSS_BUNDLE)
16 changes: 16 additions & 0 deletions html_renderer/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: https://EditorConfig.org


[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.svelte]
indent_size = 2

[*.html]
indent_size = 2
26 changes: 15 additions & 11 deletions html_renderer/.gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Log files
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local
/stats.html

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.vscode
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
*.sw?
25 changes: 25 additions & 0 deletions html_renderer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Pyinstrument</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script type="module">
import pyinstrumentHTMLRenderer from "/src/main.ts";

fetch('/sample.json')
.then(response => response.json())
.then(data => {
pyinstrumentHTMLRenderer.render(
document.getElementById('app'),
data,
)
});
</script>
</body>
</html>