gh-htmlpreview 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jay Qi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: gh-htmlpreview
3
+ Version: 0.1.0
4
+ Summary: Preview HTML files from GitHub repositories in your browser.
5
+ Keywords: github,gh-extension,html,preview
6
+ Author: Jay Qi
7
+ Author-email: Jay Qi <jayqi@users.noreply.github.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
19
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
20
+ Classifier: Topic :: Utilities
21
+ Requires-Python: >=3.11
22
+ Project-URL: Homepage, https://github.com/jayqi/gh-htmlpreview
23
+ Project-URL: Repository, https://github.com/jayqi/gh-htmlpreview
24
+ Project-URL: Changelog, https://github.com/jayqi/gh-htmlpreview/blob/main/CHANGELOG.md
25
+ Project-URL: Issues, https://github.com/jayqi/gh-htmlpreview/issues
26
+ Description-Content-Type: text/markdown
27
+
28
+ # gh-htmlpreview
29
+
30
+ [![coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/jayqi/gh-htmlpreview/badges/coverage.json)](https://github.com/jayqi/gh-htmlpreview/actions/workflows/tests.yml?query=branch%3Amain)
31
+
32
+ A GitHub CLI extension or a standalone Python CLI tool for serving a preview of an HTML file from a GitHub repository. Pass a URL for a file in a GitHub repository, and it will open your browser to a local HTTP server that serves the file and its relative assets (CSS, JavaScript, images, etc.). You can also follow links to other pages in the repository. All files are handled in memory, so no need to download files or clean them up afterwards. It can authenticate with GitHub to work with either public or private repos.
33
+
34
+ Handy for browsing things like:
35
+
36
+ - Static sites and built docs, especially in private repos
37
+ - Notebook and report exports from [Jupyter](https://jupyter.org/), [marimo](https://marimo.io/), [Quarto](https://quarto.org/), or [R Markdown](https://rmarkdown.rstudio.com/)
38
+ - Interactive charts exported to HTML, from libraries like [Plotly](https://plotly.com/), [Bokeh](https://bokeh.org/), or [Altair](https://altair-viz.github.io/)
39
+ - HTML prototypes and LLM-generated artifacts
40
+
41
+ > [!IMPORTANT]
42
+ > **Security:** The previewed page's JavaScript runs in your browser like any website's. Only preview pages from repositories you trust as much as a website you'd visit. See the [Security](#security) section for additional discussion.
43
+
44
+ > [!NOTE]
45
+ > What this tool does is similar to [htmlpreview.github.io](https://htmlpreview.github.io/), but it runs locally and can authenticate with your GitHub CLI login or a token. It does not route content through a third-party website, and it works for private repos. We are not affiliated in any way with htmlpreview.github.io.
46
+
47
+ ## Installation
48
+
49
+ ### As a GitHub CLI extension
50
+
51
+ With the [GitHub CLI](https://cli.github.com/) installed, run:
52
+
53
+ ```bash
54
+ gh extension install jayqi/gh-htmlpreview
55
+ ```
56
+
57
+ The extension needs [uv](https://docs.astral.sh/uv/) or Python 3.11 or newer on your `PATH`. With uv, it finds or downloads a suitable Python itself.
58
+
59
+ The extension tracks the `main` branch; update it with `gh extension upgrade htmlpreview`. To stay on a release instead, install with `--pin`, such as `--pin v0.1.0`.
60
+
61
+ ### As a standalone CLI tool
62
+
63
+ As a Python package from PyPI, with uv:
64
+
65
+ ```bash
66
+ uvx gh-htmlpreview URL
67
+ ```
68
+
69
+ or installed as a tool:
70
+
71
+ ```bash
72
+ uv tool install gh-htmlpreview
73
+ ```
74
+
75
+ It has no dependencies beyond the Python standard library.
76
+
77
+ ## Usage
78
+
79
+ Copy the URL of an HTML file from GitHub and pass it in:
80
+
81
+ ```bash
82
+ gh htmlpreview https://github.com/jayqi/gh-htmlpreview/blob/main/demo/index.html
83
+ ```
84
+
85
+ ```text
86
+ Serving jayqi/gh-htmlpreview@a64dfb7:demo/index.html at http://127.0.0.1:53817/demo/index.html
87
+ Shutting down after 0:30:00 without requests. Press Ctrl-C to stop.
88
+ ```
89
+
90
+ The branch or tag is resolved to a commit when it starts, and every file in the session comes from that commit. The server stops after an idle timeout without requests (by default 30 minutes, configurable with `-t`/`--timeout`), or when you press Ctrl-C.
91
+
92
+ A private repository works the same way once you're signed in to the GitHub CLI:
93
+
94
+ ```bash
95
+ gh auth login
96
+ gh htmlpreview https://github.com/my-org/private-repo/blob/main/reports/summary.html
97
+ ```
98
+
99
+ Branch names containing `/` work too:
100
+
101
+ ```bash
102
+ gh htmlpreview https://github.com/my-org/my-repo/blob/feature/new-report/docs/report.html
103
+ ```
104
+
105
+ To use the standalone Python CLI installed from PyPI, the command is `gh-htmlpreview` instead of `gh htmlpreview`.
106
+
107
+ For a shorter command, set a gh alias:
108
+
109
+ ```bash
110
+ gh alias set hp htmlpreview
111
+ gh hp https://github.com/jayqi/gh-htmlpreview/blob/main/demo/index.html
112
+ ```
113
+
114
+ ### Accepted URL formats
115
+
116
+ - `https://github.com/{owner}/{repo}/blob/{ref}/{path}`
117
+ - `https://github.com/{owner}/{repo}/raw/{ref}/{path}`
118
+ - `https://raw.githubusercontent.com/{owner}/{repo}/{ref}/{path}`
119
+
120
+ `{ref}` can be a branch, a tag, or a full commit SHA, as in GitHub's permalinks.
121
+
122
+ ### Links between pages
123
+
124
+ The whole repository at that commit is servable from the HTTP server's root, so relative links (`../index.html`) and root-relative links (`/docs/other.html`) resolve the way they would on GitHub Pages serving from the repository root. Following links from the previewed page to other HTML files in the repository works as a result, but it's best effort: a link to a directory needs a trailing slash (`articles/`) to serve its `index.html`.
125
+
126
+ Root-relative links assume the site's root is the repository's root. A site built into a subdirectory, such as `site/` or `docs/_build/html/`, works only if its links are relative. Links that leave off both the trailing slash and `.html` (`/about`) won't resolve.
127
+
128
+ ### Authentication
129
+
130
+ This tool authenticates with any GitHub token that can read the repository, such as the one from `gh auth login` or a personal access token. It checks token sources in the following order:
131
+
132
+ 1. The `GH_TOKEN` environment variable
133
+ 2. The `GITHUB_TOKEN` environment variable
134
+ 3. `gh auth token`, if the GitHub CLI is installed and signed in
135
+
136
+ If you create a personal access token for this, a fine-grained token needs the "Contents: Read-only" permission, and a classic token needs the `repo` scope for private repositories.
137
+
138
+ Without a token, public repositories still work. Files come from `raw.githubusercontent.com`, and only resolving the branch, tag, or commit uses the GitHub API, which allows 60 unauthenticated requests per hour.
139
+
140
+ ### Opening the browser
141
+
142
+ The tool will automatically open your browser to the served page. You can configure a browser command, and the configuration source follows the GitHub CLI's behavior with the following order:
143
+
144
+ - The `GH_BROWSER` environment variable
145
+ - `gh config get browser`
146
+ - The `BROWSER` environment variable
147
+ - Your system's default browser
148
+
149
+ Use `-n`/`--no-browser` to print the URL without opening a browser.
150
+
151
+ In an SSH session, or on Linux without a display, the default browser isn't opened. Over SSH, it prints the port-forwarding command to run on your own machine, such as `ssh -L 53817:127.0.0.1:53817 HOST`. Forward to the same port number and open the printed URL as is, with `127.0.0.1` rather than `localhost`, or the server refuses the request. You can use `-p`/`--port` to specify a port in order to keep the same port between sessions.
152
+
153
+ ## Security
154
+
155
+ The previewed page's JavaScript runs in your browser like any website's. **Only preview pages from repositories you trust as much as a website you'd visit.** Because browsers don't separate cookies by port, that JavaScript can read and set cookies of other apps served on `127.0.0.1`, other than HttpOnly ones. Storage the page leaves behind, such as `localStorage`, can also be seen by later web applications served at the same port.
156
+
157
+ This tool takes the following security precautions:
158
+
159
+ - The server listens on `127.0.0.1` only. It does not listen on `0.0.0.0`, which would allow other devices to connect.
160
+ - Requests must have the `Host` header `127.0.0.1:{port}`, which blocks DNS-rebinding attacks from reading repository content through the server. It also refuses `localhost`, in order to keep the cookies of other apps running on `localhost` isolated from the previewed page.
161
+ - There is an idle timeout after which the server is shut down. By default, it is 30 minutes.
162
+ - Requests from other sites are refused, based on the `Sec-Fetch-Site` header that browsers send. This includes other apps served on `127.0.0.1`.
163
+ - JavaScript service workers can't be registered, so a previewed page can't leave code behind that intercepts something else served on that port later.
164
+ - A session serves one repository at one commit. It does not mix commits or serve files across repositories.
165
+ - Your auth token is only sent to GitHub and is not accessible to the browser.
166
+
167
+ ## Limitations
168
+
169
+ - Only works for github.com. GitHub Enterprise Server is not supported.
170
+ - Git LFS files are served as their pointer files and not the files themselves.
171
+
172
+ ## CLI help
173
+
174
+ ```text
175
+ usage: gh htmlpreview [-h] [-t DURATION] [-p PORT] [-n] [--version] URL
176
+
177
+ Preview an HTML file from a GitHub repository in your browser.
178
+
179
+ positional arguments:
180
+ URL GitHub URL of the file to preview.
181
+
182
+ options:
183
+ -h, --help show this help message and exit
184
+ -t, --timeout DURATION
185
+ Time to keep the server alive after the most recent request,
186
+ such as '90s', '10m' or '1h30m'. A number without a unit is
187
+ seconds. (default: 30m)
188
+ -p, --port PORT Port to use. (default: 0, chosen by the operating system)
189
+ -n, --no-browser Print the URL without opening a browser.
190
+ --version Show version and exit.
191
+ ```
@@ -0,0 +1,164 @@
1
+ # gh-htmlpreview
2
+
3
+ [![coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/jayqi/gh-htmlpreview/badges/coverage.json)](https://github.com/jayqi/gh-htmlpreview/actions/workflows/tests.yml?query=branch%3Amain)
4
+
5
+ A GitHub CLI extension or a standalone Python CLI tool for serving a preview of an HTML file from a GitHub repository. Pass a URL for a file in a GitHub repository, and it will open your browser to a local HTTP server that serves the file and its relative assets (CSS, JavaScript, images, etc.). You can also follow links to other pages in the repository. All files are handled in memory, so no need to download files or clean them up afterwards. It can authenticate with GitHub to work with either public or private repos.
6
+
7
+ Handy for browsing things like:
8
+
9
+ - Static sites and built docs, especially in private repos
10
+ - Notebook and report exports from [Jupyter](https://jupyter.org/), [marimo](https://marimo.io/), [Quarto](https://quarto.org/), or [R Markdown](https://rmarkdown.rstudio.com/)
11
+ - Interactive charts exported to HTML, from libraries like [Plotly](https://plotly.com/), [Bokeh](https://bokeh.org/), or [Altair](https://altair-viz.github.io/)
12
+ - HTML prototypes and LLM-generated artifacts
13
+
14
+ > [!IMPORTANT]
15
+ > **Security:** The previewed page's JavaScript runs in your browser like any website's. Only preview pages from repositories you trust as much as a website you'd visit. See the [Security](#security) section for additional discussion.
16
+
17
+ > [!NOTE]
18
+ > What this tool does is similar to [htmlpreview.github.io](https://htmlpreview.github.io/), but it runs locally and can authenticate with your GitHub CLI login or a token. It does not route content through a third-party website, and it works for private repos. We are not affiliated in any way with htmlpreview.github.io.
19
+
20
+ ## Installation
21
+
22
+ ### As a GitHub CLI extension
23
+
24
+ With the [GitHub CLI](https://cli.github.com/) installed, run:
25
+
26
+ ```bash
27
+ gh extension install jayqi/gh-htmlpreview
28
+ ```
29
+
30
+ The extension needs [uv](https://docs.astral.sh/uv/) or Python 3.11 or newer on your `PATH`. With uv, it finds or downloads a suitable Python itself.
31
+
32
+ The extension tracks the `main` branch; update it with `gh extension upgrade htmlpreview`. To stay on a release instead, install with `--pin`, such as `--pin v0.1.0`.
33
+
34
+ ### As a standalone CLI tool
35
+
36
+ As a Python package from PyPI, with uv:
37
+
38
+ ```bash
39
+ uvx gh-htmlpreview URL
40
+ ```
41
+
42
+ or installed as a tool:
43
+
44
+ ```bash
45
+ uv tool install gh-htmlpreview
46
+ ```
47
+
48
+ It has no dependencies beyond the Python standard library.
49
+
50
+ ## Usage
51
+
52
+ Copy the URL of an HTML file from GitHub and pass it in:
53
+
54
+ ```bash
55
+ gh htmlpreview https://github.com/jayqi/gh-htmlpreview/blob/main/demo/index.html
56
+ ```
57
+
58
+ ```text
59
+ Serving jayqi/gh-htmlpreview@a64dfb7:demo/index.html at http://127.0.0.1:53817/demo/index.html
60
+ Shutting down after 0:30:00 without requests. Press Ctrl-C to stop.
61
+ ```
62
+
63
+ The branch or tag is resolved to a commit when it starts, and every file in the session comes from that commit. The server stops after an idle timeout without requests (by default 30 minutes, configurable with `-t`/`--timeout`), or when you press Ctrl-C.
64
+
65
+ A private repository works the same way once you're signed in to the GitHub CLI:
66
+
67
+ ```bash
68
+ gh auth login
69
+ gh htmlpreview https://github.com/my-org/private-repo/blob/main/reports/summary.html
70
+ ```
71
+
72
+ Branch names containing `/` work too:
73
+
74
+ ```bash
75
+ gh htmlpreview https://github.com/my-org/my-repo/blob/feature/new-report/docs/report.html
76
+ ```
77
+
78
+ To use the standalone Python CLI installed from PyPI, the command is `gh-htmlpreview` instead of `gh htmlpreview`.
79
+
80
+ For a shorter command, set a gh alias:
81
+
82
+ ```bash
83
+ gh alias set hp htmlpreview
84
+ gh hp https://github.com/jayqi/gh-htmlpreview/blob/main/demo/index.html
85
+ ```
86
+
87
+ ### Accepted URL formats
88
+
89
+ - `https://github.com/{owner}/{repo}/blob/{ref}/{path}`
90
+ - `https://github.com/{owner}/{repo}/raw/{ref}/{path}`
91
+ - `https://raw.githubusercontent.com/{owner}/{repo}/{ref}/{path}`
92
+
93
+ `{ref}` can be a branch, a tag, or a full commit SHA, as in GitHub's permalinks.
94
+
95
+ ### Links between pages
96
+
97
+ The whole repository at that commit is servable from the HTTP server's root, so relative links (`../index.html`) and root-relative links (`/docs/other.html`) resolve the way they would on GitHub Pages serving from the repository root. Following links from the previewed page to other HTML files in the repository works as a result, but it's best effort: a link to a directory needs a trailing slash (`articles/`) to serve its `index.html`.
98
+
99
+ Root-relative links assume the site's root is the repository's root. A site built into a subdirectory, such as `site/` or `docs/_build/html/`, works only if its links are relative. Links that leave off both the trailing slash and `.html` (`/about`) won't resolve.
100
+
101
+ ### Authentication
102
+
103
+ This tool authenticates with any GitHub token that can read the repository, such as the one from `gh auth login` or a personal access token. It checks token sources in the following order:
104
+
105
+ 1. The `GH_TOKEN` environment variable
106
+ 2. The `GITHUB_TOKEN` environment variable
107
+ 3. `gh auth token`, if the GitHub CLI is installed and signed in
108
+
109
+ If you create a personal access token for this, a fine-grained token needs the "Contents: Read-only" permission, and a classic token needs the `repo` scope for private repositories.
110
+
111
+ Without a token, public repositories still work. Files come from `raw.githubusercontent.com`, and only resolving the branch, tag, or commit uses the GitHub API, which allows 60 unauthenticated requests per hour.
112
+
113
+ ### Opening the browser
114
+
115
+ The tool will automatically open your browser to the served page. You can configure a browser command, and the configuration source follows the GitHub CLI's behavior with the following order:
116
+
117
+ - The `GH_BROWSER` environment variable
118
+ - `gh config get browser`
119
+ - The `BROWSER` environment variable
120
+ - Your system's default browser
121
+
122
+ Use `-n`/`--no-browser` to print the URL without opening a browser.
123
+
124
+ In an SSH session, or on Linux without a display, the default browser isn't opened. Over SSH, it prints the port-forwarding command to run on your own machine, such as `ssh -L 53817:127.0.0.1:53817 HOST`. Forward to the same port number and open the printed URL as is, with `127.0.0.1` rather than `localhost`, or the server refuses the request. You can use `-p`/`--port` to specify a port in order to keep the same port between sessions.
125
+
126
+ ## Security
127
+
128
+ The previewed page's JavaScript runs in your browser like any website's. **Only preview pages from repositories you trust as much as a website you'd visit.** Because browsers don't separate cookies by port, that JavaScript can read and set cookies of other apps served on `127.0.0.1`, other than HttpOnly ones. Storage the page leaves behind, such as `localStorage`, can also be seen by later web applications served at the same port.
129
+
130
+ This tool takes the following security precautions:
131
+
132
+ - The server listens on `127.0.0.1` only. It does not listen on `0.0.0.0`, which would allow other devices to connect.
133
+ - Requests must have the `Host` header `127.0.0.1:{port}`, which blocks DNS-rebinding attacks from reading repository content through the server. It also refuses `localhost`, in order to keep the cookies of other apps running on `localhost` isolated from the previewed page.
134
+ - There is an idle timeout after which the server is shut down. By default, it is 30 minutes.
135
+ - Requests from other sites are refused, based on the `Sec-Fetch-Site` header that browsers send. This includes other apps served on `127.0.0.1`.
136
+ - JavaScript service workers can't be registered, so a previewed page can't leave code behind that intercepts something else served on that port later.
137
+ - A session serves one repository at one commit. It does not mix commits or serve files across repositories.
138
+ - Your auth token is only sent to GitHub and is not accessible to the browser.
139
+
140
+ ## Limitations
141
+
142
+ - Only works for github.com. GitHub Enterprise Server is not supported.
143
+ - Git LFS files are served as their pointer files and not the files themselves.
144
+
145
+ ## CLI help
146
+
147
+ ```text
148
+ usage: gh htmlpreview [-h] [-t DURATION] [-p PORT] [-n] [--version] URL
149
+
150
+ Preview an HTML file from a GitHub repository in your browser.
151
+
152
+ positional arguments:
153
+ URL GitHub URL of the file to preview.
154
+
155
+ options:
156
+ -h, --help show this help message and exit
157
+ -t, --timeout DURATION
158
+ Time to keep the server alive after the most recent request,
159
+ such as '90s', '10m' or '1h30m'. A number without a unit is
160
+ seconds. (default: 30m)
161
+ -p, --port PORT Port to use. (default: 0, chosen by the operating system)
162
+ -n, --no-browser Print the URL without opening a browser.
163
+ --version Show version and exit.
164
+ ```
@@ -0,0 +1,98 @@
1
+ [project]
2
+ name = "gh-htmlpreview"
3
+ version = "0.1.0"
4
+ description = "Preview HTML files from GitHub repositories in your browser."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ keywords = [
9
+ "github",
10
+ "gh-extension",
11
+ "html",
12
+ "preview",
13
+ ]
14
+ classifiers = [
15
+ "Environment :: Console",
16
+ "Intended Audience :: Developers",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Programming Language :: Python :: 3.14",
23
+ "Programming Language :: Python :: 3.15",
24
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
25
+ "Topic :: Utilities",
26
+ ]
27
+ requires-python = ">=3.11"
28
+ dependencies = []
29
+
30
+ [[project.authors]]
31
+ name = "Jay Qi"
32
+ email = "jayqi@users.noreply.github.com"
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/jayqi/gh-htmlpreview"
36
+ Repository = "https://github.com/jayqi/gh-htmlpreview"
37
+ Changelog = "https://github.com/jayqi/gh-htmlpreview/blob/main/CHANGELOG.md"
38
+ Issues = "https://github.com/jayqi/gh-htmlpreview/issues"
39
+
40
+ [project.scripts]
41
+ gh-htmlpreview = "gh_htmlpreview.cli:main"
42
+
43
+ [build-system]
44
+ requires = ["uv_build>=0.13.0,<0.14.0"]
45
+ build-backend = "uv_build"
46
+
47
+ [dependency-groups]
48
+ dev = [
49
+ "ruff",
50
+ { include-group = "tests" },
51
+ { include-group = "typecheck" },
52
+ ]
53
+ tests = [
54
+ "coverage",
55
+ "pytest-cov",
56
+ "pytest",
57
+ ]
58
+ typecheck = ["ty"]
59
+ vspect = ["vspect"]
60
+
61
+ [tool.uv]
62
+ exclude-newer = "7 days"
63
+
64
+ [tool.ruff]
65
+ line-length = 99
66
+ src = [
67
+ "src",
68
+ "tests",
69
+ ]
70
+
71
+ [tool.ruff.lint]
72
+ select = [
73
+ "E",
74
+ "F",
75
+ "I",
76
+ ]
77
+ unfixable = ["F"]
78
+
79
+ [tool.ruff.lint.isort]
80
+ force-sort-within-sections = true
81
+
82
+ [tool.ty.src]
83
+ include = ["src"]
84
+
85
+ [tool.pytest.ini_options]
86
+ minversion = "6.0"
87
+ addopts = "--cov=gh_htmlpreview --cov-report=term --cov-report=html"
88
+ testpaths = ["tests"]
89
+
90
+ [tool.coverage.run]
91
+ source = ["gh_htmlpreview"]
92
+
93
+ [tool.coverage.paths]
94
+ gh_htmlpreview = [
95
+ "src/gh_htmlpreview/",
96
+ "*/src/gh_htmlpreview/",
97
+ "*/site-packages/gh_htmlpreview/",
98
+ ]
@@ -0,0 +1,96 @@
1
+ [project]
2
+ name = "gh-htmlpreview"
3
+ version = "0.1.0"
4
+ description = "Preview HTML files from GitHub repositories in your browser."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Jay Qi", email = "jayqi@users.noreply.github.com" }
8
+ ]
9
+ license = "MIT"
10
+ license-files = ["LICENSE"]
11
+ keywords = ["github", "gh-extension", "html", "preview"]
12
+ classifiers = [
13
+ "Environment :: Console",
14
+ "Intended Audience :: Developers",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python :: 3 :: Only",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Programming Language :: Python :: 3.15",
22
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
23
+ "Topic :: Utilities",
24
+ ]
25
+ requires-python = ">=3.11"
26
+ dependencies = []
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/jayqi/gh-htmlpreview"
30
+ Repository = "https://github.com/jayqi/gh-htmlpreview"
31
+ Changelog = "https://github.com/jayqi/gh-htmlpreview/blob/main/CHANGELOG.md"
32
+ Issues = "https://github.com/jayqi/gh-htmlpreview/issues"
33
+
34
+ [project.scripts]
35
+ gh-htmlpreview = "gh_htmlpreview.cli:main"
36
+
37
+ [build-system]
38
+ requires = ["uv_build>=0.13.0,<0.14.0"]
39
+ build-backend = "uv_build"
40
+
41
+ [dependency-groups]
42
+ dev = [
43
+ "ruff",
44
+ { include-group = "tests" },
45
+ { include-group = "typecheck" },
46
+ ]
47
+ tests = [
48
+ "coverage",
49
+ "pytest-cov",
50
+ "pytest",
51
+ ]
52
+ typecheck = [
53
+ "ty",
54
+ ]
55
+ vspect = [
56
+ "vspect",
57
+ ]
58
+
59
+ ## TOOLS
60
+
61
+ [tool.uv]
62
+ exclude-newer = "7 days"
63
+
64
+ [tool.ruff]
65
+ line-length = 99
66
+ src = ["src", "tests"]
67
+
68
+ [tool.ruff.lint]
69
+ select = [
70
+ "E", # Pycodestyle
71
+ "F", # Pyflakes
72
+ "I", # isort
73
+ ]
74
+ unfixable = ["F"]
75
+
76
+ [tool.ruff.lint.isort]
77
+ force-sort-within-sections = true
78
+
79
+ [tool.ty.src]
80
+ include = ["src"]
81
+
82
+ [tool.pytest.ini_options]
83
+ minversion = "6.0"
84
+ addopts = "--cov=gh_htmlpreview --cov-report=term --cov-report=html"
85
+ testpaths = ["tests"]
86
+
87
+ [tool.coverage.run]
88
+ source = ["gh_htmlpreview"]
89
+ # debug = ["pathmap"] # Useful if path mapping isn't working as expected
90
+
91
+ [tool.coverage.paths]
92
+ gh_htmlpreview = [
93
+ "src/gh_htmlpreview/",
94
+ "*/src/gh_htmlpreview/",
95
+ "*/site-packages/gh_htmlpreview/"
96
+ ]
@@ -0,0 +1,18 @@
1
+ import importlib.metadata
2
+ from pathlib import Path
3
+ import tomllib
4
+
5
+
6
+ def _version() -> str:
7
+ # Source checkout, as run by the gh extension
8
+ pyproject = Path(__file__).resolve().parents[2] / "pyproject.toml"
9
+ if pyproject.is_file():
10
+ project = tomllib.loads(pyproject.read_text(encoding="utf-8")).get("project", {})
11
+ if project.get("name") == "gh-htmlpreview":
12
+ return project["version"]
13
+ return importlib.metadata.version("gh-htmlpreview")
14
+
15
+
16
+ __version__ = _version()
17
+
18
+ __all__ = ["__version__"]
@@ -0,0 +1,3 @@
1
+ from gh_htmlpreview.cli import main
2
+
3
+ main(prog="python -m gh_htmlpreview")