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

implement documentation syncing with containerd/containerd and on-site rendering #214

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/sync-documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Sync-Documentation

on:
schedule:
- cron: '0 3 * * *'

jobs:
update-documentationmd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update documentation
id: vars
run: make refresh-docs
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ node_modules/
# Hugo-generated assets
public/
resources/
.hugo_build.lock

# Link checker assets
bin/
tmp/

# Documentation synced from other repos
content/docs/v*
static/docs/*
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[submodule "containerd1.7"]
path = containerd1.7
url = https://github.com/containerd/containerd.git
branch = release/1.7
[submodule "containerd1.6"]
path = containerd1.6
url = https://github.com/containerd/containerd.git
branch = release/1.6
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@
clean:
rm -rf public resources

serve:
refresh-docs:
./tools/refresh-docs.sh

serve: refresh-docs
hugo server \
--buildDrafts \
--buildFuture \
--disableFastRender

production-build:
production-build: refresh-docs
hugo \
--minify

preview-build:
preview-build: refresh-docs
hugo \
--baseURL $(DEPLOY_PRIME_URL) \
--buildDrafts \
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ You can also access the deploy preview for a pull request by clicking **Show all

## Contributing to the documentation

All of containerd's documentation is written in [GitHub-flavored Markdown](https://github.github.com/gfm/) and contained in the [`content/docs`](content/docs) folder.
The source of truth for containerd's documentation is the [`docs folder`](https://github.com/containerd/containerd/tree/main/docs) in the containerd/containerd repo. Documentation is syncronized to this repo daily using the [Sync-Documentation](/.github/workflows/sync-documentation.yml) workflow.

### Adding new docs

To create a new doc, add a Markdown file to `content/docs`. The name of the file will determine its URL. This doc, for example, would be available at `https://containerd.io/docs/client-libraries`:
All of containerd's documentation is written in [GitHub-flavored Markdown](https://github.github.com/gfm/). To create a new doc, add a Markdown file in the [`docs folder`](https://github.com/containerd/containerd/tree/main/docs) in the containerd/containerd repo, and it will automatically be cloned into this repo. **DO NOT WRITE DOCUMENTATION DIRECTLY TO THIS REPO -- IT WILL BE DELETED BY THE SYNC-DOCUMENTATION WORKFLOW.**

```shell
touch content/docs/client-libraries.md
```
The name, path, and release branch of the file in the containerd/containerd repo will determine its URL on this site. For example, a document committed to `https://github.com/containerd/containerd/blob/release/1.7/docs/NRI.md` would be available at `https://containerd.io/docs/v1.7.x/nri/`.

Once you've added the doc you'll need to add the following page metadata at the top, as YAML:

Expand Down
1 change: 1 addition & 0 deletions containerd1.6
Submodule containerd1.6 added at d68034
1 change: 1 addition & 0 deletions containerd1.7
Submodule containerd1.7 added at dcf284
13 changes: 8 additions & 5 deletions content/docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ short: Overview
weight: 1
---

Welcome to the containerd documentation! This document contains some basic project-level information about containerd.
## Overview

If you'd like to get started running containerd locally on your machine, see the [Getting started](https://github.com/containerd/containerd/blob/main/docs/getting-started.md) guide.
Welcome to the containerd documentation! This document contains some basic project-level information about containerd.

See also other docs: https://github.com/containerd/containerd/tree/main/docs
If you'd like to get started running containerd locally on your machine, see the [getting started](#getting-started) guide.

## Repositories

The containerd project is encapsulated in a variety of [GitHub](https://github.com) repositories.
The containerd project is encapsulated in a variety of GitHub repositories; see https://github.com/containerd .

## Getting Started

See https://github.com/containerd .
- [1.7.x](v1.7.x/docs/getting-started/)
- [1.6.x](v1.6.x/docs/getting-started/)
2 changes: 1 addition & 1 deletion content/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ short: Getting started
weight: 2
---

Moved to https://github.com/containerd/containerd/blob/main/docs/getting-started.md
This page has been consolidated to the [overview page](/docs/#getting-started)
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ publish = "public"
command = "make production-build"

[build.environment]
HUGO_VERSION = "0.111.3"
HUGO_VERSION = "0.116.0"

[context.deploy-preview]
command = "make preview-build"
Expand Down
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions themes/containerd/layouts/docs/list.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
{{ define "title" }}
containerd docs – {{ .Title }}
containerd docs – {{ cond (eq .Title "") (.File.BaseFileName | humanize | title) .Title }}
{{ end }}

{{ define "main" }}
{{- $section := .Section }}
{{- $pages := where .Site.Pages "Section" $section }}

{{ partial "hero.html" . }}
{{ partial "docs/tabs.html" (dict "pages" $pages "currentUrl" .RelPermalink) }}
{{ $Content := .Content }}

<article class="is-{{ $section }}-article">
<div class="container">
<div class="columns">
<div class="column is-three-quarters is-full-mobile">
{{ partial "docs/sidebar.html" . }}

<div class="column is-two-thirds is-full-mobile">
<div class="content">
<div class="is-hidden-desktop">
{{ partial "docs/dropdown.html" . }}
</div>

<section class="is-inner-content">
{{ .Content }}
<!-- remove instances of .md to fix links to other docs -->
{{- $content := (replaceRE `\.md` "" .Content) }}
{{ $content | safeHTML }}
</section>
</div>
</div>

<div class="column is-hidden-touch">
{{- if .TableOfContents }}
<aside class="is-toc-container">
<p class="is-size-4 is-toc-title">
Table of contents
<p class="is-toc-title">
On this page
</p>

<div id="toc">
Expand Down
18 changes: 11 additions & 7 deletions themes/containerd/layouts/docs/single.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
{{ define "title" }}
containerd docs &ndash; {{ .Title }}
{{- $title := .Title }}
containerd docs &ndash; {{ cond (eq .Title "") (.File.BaseFileName | humanize | title) .Title }}
{{ end }}

{{ define "main" }}
{{- $section := .Section }}
{{- $pages := where .Site.Pages "Section" "docs" }}

{{ partial "hero.html" . }}
{{ partial "docs/tabs.html" (dict "pages" $pages "currentUrl" .RelPermalink) }}

<article class="is-{{ $section }}-article">
<div class="container">
<div class="container margin-top: 50px">
<div class="columns">
<div class="column is-three-quarters is-full-mobile">
{{ partial "docs/sidebar.html" . }}

<div class="column is-two-thirds is-full-mobile">
<div class="content">
<div class="is-hidden-desktop">
{{ partial "docs/dropdown.html" . }}
</div>

<section class="is-inner-content">
{{ .Content }}
<!-- remove instances of .md to fix links to other docs -->
{{- $content := (replaceRE `\.md` "" .Content) }}
{{ $content | safeHTML }}
</section>
</div>
</div>
Expand All @@ -28,7 +32,7 @@
{{- if .TableOfContents }}
<aside class="is-toc-container">
<p class="is-size-4 is-toc-title">
Table of contents
On this page
</p>

<div id="toc">
Expand Down
2 changes: 1 addition & 1 deletion themes/containerd/layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<br />

<div class="buttons is-centered">
<a class="button is-medium is-radiusless is-borderless has-text-weight-bold" href="/docs/getting-started">
<a class="button is-medium is-radiusless is-borderless has-text-weight-bold" href="/docs/v1.7.x/docs/getting-started/">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to use /docs/latest and define a redirect rule that refers back to the latest version.

<span class="icon">
<i class="fas fa-sm fa-step-forward"></i>
</span>
Expand Down
17 changes: 15 additions & 2 deletions themes/containerd/layouts/partials/docs/dropdown.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{- $currentUrl := .RelPermalink }}
{{- $docs := where .Site.Pages "Section" "docs" }}
{{- $xVersion := index (findRE `v\d+\.\d+\.x` .RelPermalink) 0 }}
{{- $docs := where site.RegularPages "CurrentSection.Path" "like" (printf "%s%s%s" "/docs/" $xVersion ".*") }}

<div class="dropdown">
<div class="dropdown-trigger">
<button class="button is-dark" aria-haspopup="true" aria-controls="docs-dropdown-menu">
Expand All @@ -11,10 +13,21 @@
</div>
<div class="dropdown-menu" id="docs-dropdown-menu" role="menu">
<div class="dropdown-content">
<a class="dropdown-item{{ if eq .RelPermalink `/docs/` }} is-active{{ end }}" href="/docs">
Docs Home
</a>

{{ if (strings.Contains $xVersion "v") }}
{{- $readmeURL := (printf "%s%s%s" "/docs/" $xVersion "/") }}
<a href="{{$readmeURL}}" class="dropdown-item{{ if eq .RelPermalink $readmeURL }} is-active{{ end }}">
README
</a>
{{ end }}

{{- range $docs }}
{{- $isCurrentPage := eq $currentUrl .RelPermalink }}
<a class="dropdown-item{{ if $isCurrentPage }} is-active{{ end }}" href="{{ .RelPermalink }}">
{{ .Title }}
{{ cond (eq .Title "") (.File.BaseFileName | humanize | title) .Title }}
</a>
{{- end }}
</div>
Expand Down
14 changes: 14 additions & 0 deletions themes/containerd/layouts/partials/docs/nested-menu-partial.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ range .context.Pages }}
<li class="{{ if or (in $.ancestors .) (eq $.curRelPermalink .RelPermalink) }}active{{ end }} {{ if len .Pages }}haschildren{{ end }}">
{{ if not (len .Pages) }}
<a href="{{ .RelPermalink }}">{{ cond (eq .Title "") (.File.BaseFileName | humanize | title) .Title }}</a>
{{ else }}
<a onclick="this.parentNode.classList.contains('active') ? this.parentNode.classList.remove('active') : this.parentElement.classList.add('active')">
{{ cond (eq .Title "") (.File.BaseFileName | humanize | title) .Title }}
</a>
{{ end }}
<ul>
{{ partial "docs/nested-menu-partial.html" (dict "curRelPermalink" $.curRelPermalink "ancestors" $.ancestors "context" .) }}
</ul>
</li>
{{ end }}
43 changes: 43 additions & 0 deletions themes/containerd/layouts/partials/docs/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- $currentUrl := .RelPermalink }}
{{- $xVersion := index (findRE `v\d+\.\d+\.x` .RelPermalink) 0 }}

{{- $docs := where site.RegularPages "CurrentSection.Path" (printf "%s%s" "/docs/" $xVersion) }}

<style>
ul.nestedmenu {margin-left: 0;}
ul.nestedmenu li {list-style: none;}
ul.nestedmenu li > ul {display: none;}
ul.nestedmenu li > a::before {content: "•"; display: inline-block; margin-right: 0.25rem; width: 0.5rem; text-align: center;}
ul.nestedmenu li.haschildren > a::before {content: "›";}
ul.nestedmenu li.haschildren.active > a::before {transform: rotate(90deg);}
ul.nestedmenu li.active > ul {display: block;}
ul.nestedmenu li > a {color: #444444!important;}
ul.nestedmenu li.active > a {color: rgb(247, 44, 114)!important;}
</style>

<aside class="column is-hidden-touch is-fullheight is-hidden-mobile">
<ul class="menu-list">
<li>
<a href="/docs" class="{{ if eq .RelPermalink `/docs/` }} is-active{{ end }}">
<span class="icon"><i class="fa fa-home"></i></span> Docs Home
</a>
</li>

{{ if (strings.Contains $xVersion "v") }}
{{- $readmeURL := (printf "%s%s%s" "/docs/" $xVersion "/") }}
<li>
<a href="{{$readmeURL}}" class="{{ if eq .RelPermalink $readmeURL }} is-active{{ end }}">
<span class="icon"><i class="fa fa-info"></i></span> README
</a>
</li>
{{ end }}

{{ .Scratch.Set "ancestors" .Ancestors }}
{{ .Scratch.Set "curRelPermalink" .RelPermalink }}
{{ with .Site.GetPage (print "/docs/" $xVersion "/_index.md") }}
<ul class="nestedmenu">
{{ partial "docs/nested-menu-partial.html" (dict "curRelPermalink" ($.Scratch.Get "curRelPermalink") "ancestors" ($.Scratch.Get "ancestors") "context" .) }}
</ul>
{{ end }}
</ul>
</aside>
17 changes: 0 additions & 17 deletions themes/containerd/layouts/partials/docs/tabs.html

This file was deleted.

27 changes: 22 additions & 5 deletions themes/containerd/layouts/partials/footer.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- $logo := "img/logos/footer-logo.png" | relURL }}
{{- $docs := where .Site.Pages "Section" "docs" }}
{{- $year := now.Year }}
{{- $twitterHandle := .Site.Params.twitterHandle }}
{{- $twitterUrl := printf "https://twitter.com/@%s" $twitterHandle }}
Expand All @@ -22,13 +21,31 @@
<hr class="hr has-background-grey">

<ul>
{{- range $docs }}
<li>
<a href="{{ .RelPermalink }}">
{{ .Title }}
<a href="/docs">
Docs Home
</a>
</li>
<li>
<a href="/docs/v1.7.x/">
1.7.x README
</a>
</li>
<li>
<a href="/docs/v1.7.x/docs/getting-started/">
1.7.x Getting Started
</a>
</li>
<li>
<a href="/docs/v1.6.x/">
1.6.x README
</a>
</li>
<li>
<a href="/docs/v1.6.x/docs/getting-started/">
1.6.x Getting Started
</a>
</li>
{{- end }}
</ul>
</div>

Expand Down
Loading
Loading