-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This diff renders the Sphinx API docs in the new site Test Plan: bk Reviewers: yuhan Differential Revision: https://dagster.phacility.com/D6160
- Loading branch information
1 parent
08235c7
commit b115871
Showing
11 changed files
with
1,615 additions
and
35 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
build: | ||
pushd sphinx; popd; python pack_json.py | ||
cd sphinx; make clean; make json; cd ..; python pack_json.py |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,55 @@ | ||
import { promises as fs } from "fs"; | ||
import path from "path"; | ||
|
||
const ApiDocsPage = ({ body, data, page, curr }) => { | ||
const markup = { __html: body }; | ||
|
||
return ( | ||
<div className="flex justify-center mt-10"> | ||
<div | ||
className="prose prose-sm max-w-3xl" | ||
dangerouslySetInnerHTML={markup} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
const basePathForVersion = (version: string) => { | ||
if (version === "master") { | ||
return path.resolve("content"); | ||
} | ||
|
||
return path.resolve(".versioned_content", version); | ||
}; | ||
|
||
export async function getServerSideProps({ params, version = "master" }) { | ||
const { page } = params; | ||
|
||
const basePath = basePathForVersion(version); | ||
const pathToFile = path.resolve(basePath, "api/sections.json"); | ||
|
||
try { | ||
const buffer = await fs.readFile(pathToFile); | ||
const { | ||
api: { apidocs: data }, | ||
} = JSON.parse(buffer.toString()); | ||
|
||
let curr = data; | ||
for (const part of page) { | ||
curr = curr[part]; | ||
} | ||
|
||
const { body } = curr; | ||
|
||
return { | ||
props: { body, data, page, curr }, | ||
}; | ||
} catch (err) { | ||
console.log(err); | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
} | ||
|
||
export default ApiDocsPage; |
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,9 @@ | ||
const APIDocsIndex = () => { | ||
return ( | ||
<div className="prose"> | ||
<h1>API Documentation Reference</h1> | ||
</div> | ||
); | ||
}; | ||
|
||
export default APIDocsIndex; |
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,54 @@ | ||
import { promises as fs } from "fs"; | ||
import path from "path"; | ||
|
||
const ApiDocsPage = ({ body, data, page, curr }) => { | ||
const markup = { __html: body }; | ||
|
||
return ( | ||
<div className="flex justify-center mt-10"> | ||
<div | ||
className="prose prose-sm max-w-none" | ||
dangerouslySetInnerHTML={markup} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
const basePathForVersion = (version: string) => { | ||
if (version === "master") { | ||
return path.resolve("content"); | ||
} | ||
|
||
return path.resolve(".versioned_content", version); | ||
}; | ||
|
||
export async function getServerSideProps({ params, version = "master" }) { | ||
const { page } = params; | ||
|
||
const basePath = basePathForVersion(version); | ||
const pathToFile = path.resolve(basePath, "api/modules.json"); | ||
|
||
try { | ||
const buffer = await fs.readFile(pathToFile); | ||
|
||
const data = JSON.parse(buffer.toString()); | ||
|
||
let curr = data; | ||
for (const part of page) { | ||
curr = curr[part]; | ||
} | ||
|
||
const { body } = curr; | ||
|
||
return { | ||
props: { body, data, page, curr }, | ||
}; | ||
} catch (err) { | ||
console.log(err); | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
} | ||
|
||
export default ApiDocsPage; |
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,9 @@ | ||
const APIDocsIndex = () => { | ||
return ( | ||
<div className="prose"> | ||
<h1>API Documentation Reference</h1> | ||
</div> | ||
); | ||
}; | ||
|
||
export default APIDocsIndex; |
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