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

Documentation website #1526

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
200eeb3
Add scripts for website generation
emlai Jul 21, 2022
013d915
Add mkdocs config and hook for fixing absolute links
emlai Jul 21, 2022
ca333f4
Add docusaurus configuration
emlai Jul 23, 2022
9c60428
Fix some markdown documents for docusaurus
emlai Jul 23, 2022
8915fc4
Move website sources under website/
emlai Jul 23, 2022
db15586
Fix absolute path URLs
emlai Jul 23, 2022
31323f7
Fix edit links
emlai Jul 23, 2022
ff2aee4
Merge branch 'trunk' into website
emlai Jul 23, 2022
0e60e88
Remove mkdocs configs
emlai Jul 23, 2022
38c5afe
Use multiple sidebars instead of multiple docs plugins
emlai Jul 24, 2022
65d62e7
Exclude docs/README.md to fix "Duplicate routes found" warning
emlai Jul 24, 2022
4d5481a
Fix front page links
emlai Jul 24, 2022
9f30df7
Fix links on spec page
emlai Jul 24, 2022
b9c6261
Fix image links on front page
emlai Jul 24, 2022
8c01482
Add comment about front page pipe characters
emlai Jul 24, 2022
c209d44
Fix "<br/>" being displayed as text in front page tab title
emlai Jul 24, 2022
d3d347b
Add GitHub Actions workflow for deploying the website
emlai Jul 24, 2022
eb26f3d
Use npm instead of yarn
emlai Jul 24, 2022
b5a544d
Add "Setting up GitHub Actions auto-deployment" instructions
emlai Jul 24, 2022
6a6510f
Create deployment commits as github-actions user
emlai Jul 24, 2022
22e9504
Remove table-of-contents enclosed in `toc` and `tocstop` comments
emlai Jul 25, 2022
d872561
Add reminder at the top that Carbon is not production-ready
emlai Jul 25, 2022
974ca79
Update onBrokenMarkdownLinks comment
emlai Jul 25, 2022
9a48e2c
Merge branch 'trunk' into website
emlai Jul 27, 2022
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
38 changes: 38 additions & 0 deletions .github/workflows/deploy-website.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy Website

on:
push:
branches:
- trunk
paths:
- 'README.md'
- 'docs/**'
- 'website/**'

jobs:
deploy:
name: Deploy Website
runs-on: ubuntu-latest
defaults:
run:
working-directory: website
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: website/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build website
run: npm run build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir: ./website/build
external_repository: carbon-language/carbon-language.github.io
publish_branch: trunk
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
# Carbon Language: <br/> An experimental successor to C++
# Carbon Language: an experimental successor to C++

<!--
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
Exceptions. See /LICENSE for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-->

<!-- Keep these links on one line so the pipes are spaced correctly on the website. -->
<p align="center">
<a href="#why-build-carbon">Why?</a> |
<a href="#language-goals">Goals</a> |
<a href="#project-status">Status</a> |
<a href="#getting-started">Getting started</a> |
<a href="#join-us">Join us</a>
<a href="#why-build-carbon">Why?</a> | <a href="#language-goals">Goals</a> | <a href="#project-status">Status</a> | <a href="#getting-started">Getting started</a> | <a href="#join-us">Join us</a>
</p>

**See our [announcement video](https://youtu.be/omrY53kbVoA) from
[CppNorth](https://cppnorth.ca/).** Note that Carbon is
[not ready for use](#project-status).

<a href="docs/images/snippets.md#quicksort">
<!--
Edit snippet in docs/images/snippets.md and:
https://drive.google.com/drive/folders/1-rsUjiya7dSZ87L8kpZmu3MZghRVxzLA
-->
<a href="docs/images/snippets.md#quicksort">
<img src="docs/images/quicksort_snippet.svg" align="right" width="575"
alt="Quicksort code in Carbon. Follow the link to read more.">
alt="Quicksort code in Carbon. Follow the link to read more."/>
</a>

<!--
Don't let the text wrap too narrowly to the left of the above image.
The `div` reduces the vertical height.
GitHub will autolink `img`, but won't produce a link when `href="#"`.
-->
<div><a href="#"><img src="docs/images/bumper.png"></a></div>
<div><a href="#"><img src="docs/images/bumper.png"/></a></div>

**Fast and works with C++**

Expand Down Expand Up @@ -169,37 +166,37 @@ familiar and be easy to read and understand.

C++ code like this:

<a href="docs/images/snippets.md#c">
<!--
Edit snippet in docs/images/snippets.md and:
https://drive.google.com/drive/folders/1-rsUjiya7dSZ87L8kpZmu3MZghRVxzLA
-->
<a href="docs/images/snippets.md#c">
<img src="docs/images/cpp_snippet.svg" width="600"
alt="A snippet of C++ code. Follow the link to read it.">
alt="A snippet of C++ code. Follow the link to read it."/>
</a>

corresponds to this Carbon code:

<a href="docs/images/snippets.md#carbon">
<!--
Edit snippet in docs/images/snippets.md and:
https://drive.google.com/drive/folders/1-rsUjiya7dSZ87L8kpZmu3MZghRVxzLA
-->
<a href="docs/images/snippets.md#carbon">
<img src="docs/images/carbon_snippet.svg" width="600"
alt="A snippet of converted Carbon code. Follow the link to read it.">
alt="A snippet of converted Carbon code. Follow the link to read it."/>
</a>

You can call Carbon from C++ without overhead and the other way around. This
means you migrate a single C++ library to Carbon within an application, or write
new Carbon on top of your existing C++ investment. For example:

<a href="docs/images/snippets.md#mixed">
<!--
Edit snippet in docs/images/snippets.md and:
https://drive.google.com/drive/folders/1-rsUjiya7dSZ87L8kpZmu3MZghRVxzLA
-->
<a href="docs/images/snippets.md#mixed">
<img src="docs/images/mixed_snippet.svg" width="600"
alt="A snippet of mixed Carbon and C++ code. Follow the link to read it.">
alt="A snippet of mixed Carbon and C++ code. Follow the link to read it."/>
</a>

Read more about
Expand Down
8 changes: 4 additions & 4 deletions docs/project/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,24 +168,24 @@ expect the vast majority of code to interoperate well.

For example, considering a pure C++ application:

<a href="/docs/images/snippets.md#c">
<!--
Edit snippet in /docs/images/snippets.md and:
https://drive.google.com/drive/folders/1-rsUjiya7dSZ87L8kpZmu3MZghRVxzLA
-->
<a href="/docs/images/snippets.md#c">
<img src="/docs/images/cpp_snippet.svg" width="600"
alt="A snippet of C++ code. Follow the link to read it.">
alt="A snippet of C++ code. Follow the link to read it."/>
</a>

It's possible to migrate a single function to Carbon:

<a href="/docs/images/snippets.md#mixed">
<!--
Edit snippet in /docs/images/snippets.md and:
https://drive.google.com/drive/folders/1-rsUjiya7dSZ87L8kpZmu3MZghRVxzLA
-->
<a href="/docs/images/snippets.md#mixed">
<img src="/docs/images/mixed_snippet.svg" width="600"
alt="A snippet of mixed Carbon and C++ code. Follow the link to read it.">
alt="A snippet of mixed Carbon and C++ code. Follow the link to read it."/>
</a>

References:
Expand Down
2 changes: 1 addition & 1 deletion proposals/p0555.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ left-to-right arrow meaning a left-associative operator.
For example:

<div align="center">
<img src="p0555/example.svg" alt="Example operator precedence diagram">
<img src="p0555/example.svg" alt="Example operator precedence diagram"/>
</div>

... would depict a higher-precedence `*` operator and a lower-precedence `+`
Expand Down
20 changes: 20 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
53 changes: 53 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Website

This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.

### Installation

```
$ npm install
```

### Local development

```
$ npm start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ npm run build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

Using SSH:

```
$ USE_SSH=true npm run deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> npm run deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

### Setting up GitHub Actions auto-deployment

The [deployment workflow](../.github/workflows/deploy-website.yaml) is configured to deploy to `carbon-language.github.io` using [deploy keys](https://docs.github.com/en/developers/overview/managing-deploy-keys).
(Personal access tokens can also be used via [`personal_token`](https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-deploy-to-external-repository-external_repository).)

To configure the required deploy keys:

1. Create a new SSH key pair according to the [GitHub docs](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key).
2. Add the private key to the "Repository secrets" section of repository which runs the workflow, name it `ACTIONS_DEPLOY_KEY`.
3. Add the public key to the "Deploy keys" section of the target deployment repository and enable "Allow write access".
4. The next time the GitHub Actions workflow runs, it will use these keys to deploy the website.
3 changes: 3 additions & 0 deletions website/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
113 changes: 113 additions & 0 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
const transformLinks = require('./src/plugins/transformLinks');
const transformImageLinks = require('./src/plugins/transformImageLinks');
const removeTableOfContents = require('./src/plugins/removeTableOfContents');

/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Carbon Language',
tagline: 'An experimental successor to C++',
url: 'https://carbon-language.github.io',
baseUrl: '/',
onBrokenLinks: 'ignore', // TODO: Fix broken links, and change this back to 'throw'
onBrokenMarkdownLinks: 'ignore', // These are fixed in `transformLinks`.
favicon: 'img/carbon-logo.png',

// GitHub pages deployment config.
organizationName: 'carbon-language',
projectName: 'carbon-language.github.io',
trailingSlash: true, // Fixes relative directory links on e.g. Spec page.

i18n: {
defaultLocale: 'en',
locales: ['en'],
},

presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
path: '..',
routeBasePath: '/',
include: ['docs/**/*.{md,mdx}', 'README.md'],
sidebarPath: require.resolve('./sidebars.js'),
editUrl: 'https://github.com/carbon-language/carbon-lang/blob/trunk/docs',
beforeDefaultRemarkPlugins: [removeTableOfContents, transformLinks],
rehypePlugins: [transformImageLinks],
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
}),
],
],

themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
colorMode: {
defaultMode: 'light',
disableSwitch: false,
respectPrefersColorScheme: true,
},
announcementBar: {
content: '⚠️ Carbon is experimental and not production-ready, see ' +
'<a href="/docs/project/faq#how-soon-can-we-use-carbon">How soon can we use Carbon?</a>',
backgroundColor: 'var(--ifm-navbar-background-color)',
textColor: 'var(--ifm-font-color-base)',
isCloseable: true,
},
navbar: {
title: 'Carbon Language',
logo: {
alt: 'Carbon Logo',
src: 'img/carbon-logo.png',
},
items: [
{ to: '/docs/design', label: 'Design', position: 'left' },
{ to: '/docs/project', label: 'Project', position: 'left' },
{ to: '/docs/guides', label: 'Guides', position: 'left' },
{ to: '/docs/spec', label: 'Spec', position: 'left' },
{
href: 'https://github.com/carbon-language/carbon-lang',
label: 'GitHub',
position: 'right',
},
],
},
footer: {
style: 'dark',
links: [
{
title: 'Community',
items: [
{
label: 'GitHub',
href: 'https://github.com/carbon-language/carbon-lang',
},
{
label: 'Discord',
href: 'https://discord.gg/ZjVdShJDAs',
},
{
label: 'Code of Conduct',
href: 'https://github.com/carbon-language/carbon-lang/blob/trunk/CODE_OF_CONDUCT.md',
},
],
},
],
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},
}),
};

module.exports = config;