mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2026-02-06 14:02:19 +08:00
Setup website with docusaurus (#11)
Summary: Set up landing page, docs page, and html versions of the ipython notebook tutorials. Pull Request resolved: https://github.com/fairinternal/pytorch3d/pull/11 Reviewed By: gkioxari Differential Revision: D19730380 Pulled By: nikhilaravi fbshipit-source-id: 5df8d3f2ac2f8dce4d51f5d14fc336508c2fd0ea
This commit is contained in:
committed by
Facebook Github Bot
parent
e290f87ca9
commit
15d3a4557e
72
website/core/Footer.js
Normal file
72
website/core/Footer.js
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
*/
|
||||
const PropTypes = require("prop-types");
|
||||
const React = require('react');
|
||||
|
||||
function SocialFooter(props) {
|
||||
const repoUrl = `https://github.com/${props.config.organizationName}/${props.config.projectName}`;
|
||||
return (
|
||||
<div className="footerSection">
|
||||
<div className="social">
|
||||
<a
|
||||
className="github-button" // part of the https://buttons.github.io/buttons.js script in siteConfig.js
|
||||
href={repoUrl}
|
||||
data-count-href={`${repoUrl}/stargazers`}
|
||||
data-show-count="true"
|
||||
data-count-aria-label="# stargazers on GitHub"
|
||||
aria-label="Star PyTorch3d on GitHub"
|
||||
>
|
||||
{props.config.projectName}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
SocialFooter.propTypes = {
|
||||
config: PropTypes.object
|
||||
};
|
||||
|
||||
class Footer extends React.Component {
|
||||
docUrl(doc, language) {
|
||||
const baseUrl = this.props.config.baseUrl;
|
||||
const docsUrl = this.props.config.docsUrl;
|
||||
const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`;
|
||||
const langPart = `${language ? `${language}/` : ''}`;
|
||||
return `${baseUrl}${docsPart}${langPart}${doc}`;
|
||||
}
|
||||
|
||||
pageUrl(doc, language) {
|
||||
const baseUrl = this.props.config.baseUrl;
|
||||
return baseUrl + (language ? `${language}/` : '') + doc;
|
||||
}
|
||||
|
||||
render() {
|
||||
const repoUrl = `https://github.com/${this.props.config.organizationName}/${this.props.config.projectName}`;
|
||||
return (
|
||||
<footer className="nav-footer" id="footer">
|
||||
<section className="sitemap">
|
||||
<SocialFooter config={this.props.config} />
|
||||
</section>
|
||||
|
||||
<a
|
||||
href="https://opensource.facebook.com/"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
className="fbOpenSource">
|
||||
<img
|
||||
src={`${this.props.config.baseUrl}img/oss_logo.png`}
|
||||
alt="Facebook Open Source"
|
||||
width="170"
|
||||
height="45"
|
||||
/>
|
||||
</a>
|
||||
<section className="copyright">{this.props.config.copyright}</section>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Footer;
|
||||
87
website/core/Tutorial.js
Normal file
87
website/core/Tutorial.js
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* @format
|
||||
*/
|
||||
|
||||
const React = require('react');
|
||||
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const CWD = process.cwd();
|
||||
|
||||
const CompLibrary = require(`${CWD}/node_modules/docusaurus/lib/core/CompLibrary.js`);
|
||||
const Container = CompLibrary.Container;
|
||||
|
||||
const TutorialSidebar = require(`${CWD}/core/TutorialSidebar.js`);
|
||||
|
||||
function renderDownloadIcon() {
|
||||
return (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
data-prefix="fas"
|
||||
data-icon="file-download"
|
||||
className="svg-inline--fa fa-file-download fa-w-12"
|
||||
role="img"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 384 512">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm76.45 211.36l-96.42 95.7c-6.65 6.61-17.39 6.61-24.04 0l-96.42-95.7C73.42 337.29 80.54 320 94.82 320H160v-80c0-8.84 7.16-16 16-16h32c8.84 0 16 7.16 16 16v80h65.18c14.28 0 21.4 17.29 11.27 27.36zM377 105L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
class Tutorial extends React.Component {
|
||||
render() {
|
||||
const {baseUrl, tutorialID} = this.props;
|
||||
|
||||
const htmlFile = `${CWD}/_tutorials/${tutorialID}.html`;
|
||||
const normalizedHtmlFile = path.normalize(htmlFile);
|
||||
|
||||
return (
|
||||
<div className="docMainWrapper wrapper">
|
||||
<TutorialSidebar currentTutorialID={tutorialID} />
|
||||
<Container className="mainContainer">
|
||||
<div className="tutorialButtonsWrapper">
|
||||
<div className="colabButtonWrapper">
|
||||
<a
|
||||
href={`https://colab.research.google.com/github/facebookresearch/pytorch3d/blob/master/docs/tutorials/${tutorialID}.ipynb`}>
|
||||
<img align="left" src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
|
||||
</a>
|
||||
</div>
|
||||
<div className="tutorialButtonWrapper buttonWrapper">
|
||||
<a
|
||||
className="tutorialButton button"
|
||||
download
|
||||
href={`${baseUrl}files/${tutorialID}.ipynb`}
|
||||
target="_blank">
|
||||
{renderDownloadIcon()}
|
||||
{'Download Tutorial Jupyter Notebook'}
|
||||
</a>
|
||||
</div>
|
||||
<div className="tutorialButtonWrapper buttonWrapper">
|
||||
<a
|
||||
className="tutorialButton button"
|
||||
download
|
||||
href={`${baseUrl}files/${tutorialID}.py`}
|
||||
target="_blank">
|
||||
{renderDownloadIcon()}
|
||||
{'Download Tutorial Source Code'}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="tutorialBody"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: fs.readFileSync(normalizedHtmlFile, {encoding: 'utf8'}),
|
||||
}}
|
||||
/>
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Tutorial;
|
||||
88
website/core/TutorialSidebar.js
Normal file
88
website/core/TutorialSidebar.js
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* @format
|
||||
*/
|
||||
|
||||
const React = require('react');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const join = path.join;
|
||||
const CWD = process.cwd();
|
||||
|
||||
const CompLibrary = require(join(
|
||||
CWD,
|
||||
'/node_modules/docusaurus/lib/core/CompLibrary.js',
|
||||
));
|
||||
const SideNav = require(join(
|
||||
CWD,
|
||||
'/node_modules/docusaurus/lib/core/nav/SideNav.js',
|
||||
));
|
||||
|
||||
const Container = CompLibrary.Container;
|
||||
|
||||
const OVERVIEW_ID = 'tutorial_overview';
|
||||
|
||||
class TutorialSidebar extends React.Component {
|
||||
render() {
|
||||
const {currentTutorialID} = this.props;
|
||||
const current = {
|
||||
id: currentTutorialID || OVERVIEW_ID,
|
||||
};
|
||||
|
||||
const toc = [
|
||||
{
|
||||
type: 'CATEGORY',
|
||||
title: 'Tutorials',
|
||||
children: [
|
||||
{
|
||||
type: 'LINK',
|
||||
item: {
|
||||
permalink: 'tutorials/',
|
||||
id: OVERVIEW_ID,
|
||||
title: 'Overview',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const jsonFile = join(CWD, 'tutorials.json');
|
||||
const normJsonFile = path.normalize(jsonFile);
|
||||
const json = JSON.parse(fs.readFileSync(normJsonFile, {encoding: 'utf8'}));
|
||||
|
||||
Object.keys(json).forEach(category => {
|
||||
const categoryItems = json[category];
|
||||
const items = [];
|
||||
categoryItems.map(item => {
|
||||
items.push({
|
||||
type: 'LINK',
|
||||
item: {
|
||||
permalink: `tutorials/${item.id}`,
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
toc.push({
|
||||
type: 'CATEGORY',
|
||||
title: category,
|
||||
children: items,
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
<Container className="docsNavContainer" id="docsNav" wrapper={false}>
|
||||
<SideNav
|
||||
language={'tutorials'}
|
||||
root={'tutorials'}
|
||||
title="Tutorials"
|
||||
contents={toc}
|
||||
current={current}
|
||||
/>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TutorialSidebar;
|
||||
Reference in New Issue
Block a user