Skip to content

Commit 6a1ca40

Browse files
authored
remove docs banner (#1110)
1 parent df71c6f commit 6a1ca40

File tree

4 files changed

+7
-94
lines changed

4 files changed

+7
-94
lines changed

docs-site/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# docs site
2+
3+
This is a [cloudflare workers static assets](https://developers.cloudflare.com/workers/static-assets/)
4+
site used to host the documentation.
5+
6+
We're currently not using all the features of static assets, but we'll keep this structure in case they're
7+
needed in the future.

docs-site/src/index.ts

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -6,92 +6,7 @@ export default {
66
url.pathname = '/404.html'
77
const r = await env.ASSETS.fetch(url)
88
return new Response(r.body, { status: 404 })
9-
} else if (r.status == 200) {
10-
const contentType = r.headers.get('content-type')
11-
if (contentType && contentType.includes('text/html')) {
12-
const handler = new InsertVersionNoticeHandler(request, env)
13-
return new HTMLRewriter().on('div#version-notice', handler).transform(r);
14-
}
159
}
1610
return r
1711
},
1812
} satisfies ExportedHandler<Env>
19-
20-
class InsertVersionNoticeHandler {
21-
readonly request: Request
22-
readonly env: Env
23-
24-
constructor(request: Request, env: Env) {
25-
this.request = request
26-
this.env = env
27-
}
28-
29-
async element(element: Element): Promise<void> {
30-
try {
31-
const warning = await this.getVersionNotice()
32-
element.setInnerContent(warning, {html: true})
33-
} catch (e) {
34-
// catch the error and log it, but do not raise it so the site can still be served
35-
console.error(e)
36-
}
37-
}
38-
async getVersionNotice(): Promise<string> {
39-
const cacheKey = `version-notice-${this.env.GIT_BRANCH}-${this.env.GIT_COMMIT_SHA}`
40-
let versionNotice = await this.env.VERSION_NOTICE_CACHE.get(cacheKey, {cacheTtl: 60})
41-
if (versionNotice === null) {
42-
versionNotice = await this.fetchVersionNotice()
43-
await this.env.VERSION_NOTICE_CACHE.put(cacheKey, versionNotice, {expirationTtl: 300})
44-
}
45-
return versionNotice
46-
}
47-
48-
async fetchVersionNotice(): Promise<string> {
49-
const headers = {
50-
'User-Agent': this.request.headers.get('User-Agent') || 'pydantic-ai-docs',
51-
'Accept': 'application/vnd.github.v3+json',
52-
}
53-
const r1 = await fetch('https://api.github.com/repos/pydantic/pydantic-ai/releases/latest', {headers})
54-
if (!r1.ok) {
55-
const text = await r1.text()
56-
throw new Error(`Failed to fetch latest release, response status ${r1.status}:\n${text}`)
57-
}
58-
const {html_url, name, tag_name}: ReleaseInfo = await r1.json()
59-
const r2 = await fetch(
60-
`https://api.github.com/repos/pydantic/pydantic-ai/compare/${tag_name}...${this.env.GIT_COMMIT_SHA}`,
61-
{headers}
62-
)
63-
if (!r2.ok) {
64-
const text = await r2.text()
65-
throw new Error(`Failed to fetch compare, response status ${r2.status}:\n${text}`)
66-
}
67-
const {ahead_by}: TagInfo = await r2.json()
68-
69-
if (ahead_by === 0) {
70-
return `<div class="admonition success" style="margin: 0">
71-
<p class="admonition-title">Version</p>
72-
<p>Showing documentation for the latest release <a href="${html_url}">${name}</a>.</p>
73-
</div>`
74-
}
75-
76-
const branch = this.env.GIT_BRANCH
77-
const diff_html_url = `https://github.com/pydantic/pydantic-ai/compare/${tag_name}...${branch}`
78-
return `<div class="admonition info" style="margin: 0">
79-
<p class="admonition-title">Version Notice</p>
80-
<p>
81-
${branch === 'main' ? '' : `(<b>${branch}</b> preview)`}
82-
This documentation is ahead of the last release by
83-
<a href="${diff_html_url}">${ahead_by} commit${ahead_by === 1 ? '' : 's'}</a>.
84-
You may see documentation for features not yet supported in the latest release <a href="${html_url}">${name}</a>.
85-
</p>
86-
</div>`
87-
}
88-
}
89-
90-
interface ReleaseInfo {
91-
html_url: string
92-
name: string
93-
tag_name: string
94-
}
95-
interface TagInfo {
96-
ahead_by: number
97-
}

docs/.overrides/main.html

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/index.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
--8<-- "docs/.partials/index-header.html"
44

5-
PydanticAI is a Python Agent Framework designed to make it less painful to
6-
build production grade applications with Generative AI.
7-
85
FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of [Pydantic](https://docs.pydantic.dev).
96

107
Similarly, virtually every agent framework and LLM library in Python uses Pydantic, yet when we began to use LLMs in [Pydantic Logfire](https://pydantic.dev/logfire), we couldn't find anything that gave us the same feeling.

0 commit comments

Comments
 (0)