Skip to content

Commit 4d0b9ce

Browse files
authored
docs: add to contribution guide: images, pre-commit, etc. (#122)
1 parent 65ab458 commit 4d0b9ce

File tree

4 files changed

+111
-47
lines changed

4 files changed

+111
-47
lines changed

README.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,3 @@ See also the Contribution Guide articles:
1717

1818
- [Contribution workflow](./content/pages/contribution-guide/contrib-workflow/index.md)
1919
- [Writing content](./content/pages/contribution-guide/writing-content/index.md)
20-
21-
22-
## Use pre-commit
23-
24-
This project has a [pre-commit][] hook that can perform the following checks:
25-
26-
- Enforce coding standards and best practices in the project's codebase
27-
- Check links using [lychee][]
28-
- **Important**: requires Docker
29-
- `lychee` also runs as a GitHub action on pushes to main
30-
31-
[pre-commit]: https://pre-commit.com/
32-
[lychee]: https://github.com/lycheeverse/lychee
33-
34-
If you want to use pre-commit, in your project folder, run:
35-
36-
```sh
37-
# Install requirements
38-
pip install -r requirements.txt
39-
# Set up git hook scripts
40-
pre-commit install
41-
# Remove git hook scripts (if not needed)
42-
pre-commit uninstall
43-
```

content/pages/contribution-guide/asciinema-casts/index.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
title: "asciinema casts"
33
date: 2024-03-18T10:55:37+01:00
44
tags: ["Contribute"]
5+
showTableOfContents: true
56
showAuthor: false
67
authors:
78
- "kirill-chalov"
89
---
910

1011
## Overview
1112

12-
You can easily embed asciinema casts on the Developer Portal. asciinema allows you to record terminal sessions using a lightweight text-based format.
13+
[asciinema](https://asciinema.org/) allows you to record terminal sessions using a lightweight text-based format. You can easily embed asciinema casts on the Developer Portal.
1314

1415
### Notable features
1516

@@ -28,15 +29,26 @@ Use asciinema casts for output logs or to demonstrate things in action. Avoid us
2829

2930
1. Install asciinema and record a terminal session following the [Quick start](https://docs.asciinema.org/manual/cli/quick-start/) guide.
3031
2. Edit the `.cast` file if required.
31-
3. Add the .cast file in the same directory as your page.
32-
4. Add a Hugo shortcode to your page:<br>
33-
\{\{< asciinema key="demo" idleTimeLimit="2" speed="1.5" poster="npt:0:09" >\}\}
34-
- The file added is `demo.cast`
35-
- See also the [asciinema player options](https://docs.asciinema.org/manual/player/options/)
32+
3. Add the .cast file in the same directory as your article.
33+
4. Embed a Hugo shortcode in your article.<br>
34+
For example, the shortcode below embeds the file `demo.cast` and adjusts some [asciinema player options](https://docs.asciinema.org/manual/player/options/):
35+
```md
36+
{{</* asciinema
37+
key="demo"
38+
idleTimeLimit="2"
39+
speed="1.5"
40+
poster="npt:0:09"
41+
*/>}}
42+
```
3643

3744
The above shortcode will be rendered as follows:
3845

39-
{{< asciinema key="demo" idleTimeLimit="2" speed="1.5" poster="npt:0:09" >}}
46+
{{< asciinema
47+
key="demo"
48+
idleTimeLimit="2"
49+
speed="1.5"
50+
poster="npt:0:09"
51+
>}}
4052
4153
### How to embed a cast from asciinema.org
4254

content/pages/contribution-guide/contrib-workflow/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ The contribution diagram below shows how contributions can be done to [espressif
1515

1616
```mermaid
1717
flowchart RL
18-
id1[Public \nUpstream]
19-
id2[Private \nmirror]
20-
id3[Public \nFork]
21-
id4[Private \nmirror]
22-
id5[Public \nFork]
18+
id1[Public<br>Upstream]
19+
id2[Private<br>mirror]
20+
id3[Public<br>Fork]
21+
id4[Private<br>mirror]
22+
id5[Public<br>Fork]
2323
subgraph sg1 [GitHub]
2424
id1
2525
id3
@@ -31,9 +31,9 @@ flowchart RL
3131
subgraph sg3 [Anywhere]
3232
id4
3333
end
34-
id2 -- Internal \ncontributions \n(private) ---> id1
35-
id3 -. External \ncontributions \n(public) .-> id1
36-
id4 -. External \ncontributions \n(private) .-> id5
34+
id2 -- Internal<br>contributions<br>(private) ---> id1
35+
id3 -. External<br>contributions<br>(public) .-> id1
36+
id4 -. External<br>contributions<br>(private) .-> id5
3737
id5 -.-> id1
3838
style id1 fill:#99f
3939
classDef dashedStyle stroke-width:1px,stroke-dasharray: 5 5;

content/pages/contribution-guide/writing-content/index.md

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ This is totally up to you how you write the content as long as it is valuable fo
6363
6464
For writing and formatting conventions, the contributors at Espressif usually follow the [Espressif Manual of Style](https://mos.espressif.com/) and the *Chicago Manual of Style*. You might find these guidelines useful, but you are not required to follow them.
6565
66-
## Prepare a featured image
66+
### Prepare a featured image
6767
6868
A featured image appears above the article's title. A nice and relevant image attracts readers like a magnet, that is why consider giving more thought to it.
6969
@@ -80,18 +80,74 @@ A featured image can be added in the following ways from the highest to lowest p
8080
featureAsset: "img/featured/image.webp"
8181
```
8282

83+
Please have your featured image converted to WebP as requested in [Use WebP for raster images](#use-webp-for-raster-images).
84+
8385
[blowfish-front-matter]: https://blowfish.page/docs/front-matter/
8486

8587
## Use additional content types
8688

87-
Apart from the usual content types supported by markdown, such as visuals or code blocks, you can use other content types enabled by Hugo shortcodes. This section briefly introduces them.
89+
Apart from the usual content types supported by markdown, such as visuals or code blocks, you can use other content types enabled by Hugo shortcodes. This section briefly introduces the most relevant shortcodes implemented on the Espressif Developer Portal.
90+
91+
In addition to that, you can also use the standard Hugo [embedded shortcodes](https://gohugo.io/content-management/shortcodes/#embedded-shortcodes) and [Blowfish theme shortcodes](https://blowfish.page/docs/shortcodes/).
8892

89-
If you need other types of content, either create a discussion on GitHub or offer a PR with the required functionality. It will be very much appreciated!
93+
If you need other content types or shortcodes implemented, either create a discussion on GitHub or offer a PR with the required functionality. It will be very much appreciated!
9094

9195

9296
### Images
9397

98+
#### Adding images
99+
100+
You can add an image using a standard markdown syntax:
101+
102+
```md
103+
![Alt text](path/to/image.webp "Optional tooltip")
104+
```
105+
106+
However, the Blowfish theme used on this website provides the [figure](https://blowfish.page/docs/shortcodes/#figure) shortcode that offers more control over image display and render. An example of a shortcode is given below, but more parameters are available:
107+
108+
```md
109+
{{</* figure
110+
src="image.webp"
111+
alt=""
112+
caption=""
113+
*/>}}
114+
```
115+
116+
By default, the Blowfish theme optimizes the images for different device resolutions. For some images, the processing **adds grey background**. To fix it, disable the processing of such images by adding the parameter `default="false"` to the figure shortcode.
117+
118+
119+
#### Use WebP for raster images
120+
121+
For raster images, please use the WebP format only. The Developer Portal's CI blocks the images in PNG anf JPEG format.
122+
123+
The WebP format was chosen for the following reasons:
94124

125+
- The images in WebP are comparable in quality to PNG and JPEG but are 5-7 times smaller in size
126+
- Smaller image size is important
127+
- It prevents the git repo from growing out of proportion very fast
128+
- It allows serving web pages faster
129+
130+
To convert your images to WebP, use one of the following ways:
131+
132+
- Use [imagemagick](https://imagemagick.org/script/download.php):
133+
134+
```sh
135+
convert image.jpg -quality 60 image.webp
136+
```
137+
- Use [cwebp](https://developers.google.com/speed/webp/download):
138+
139+
```sh
140+
cwebp -q 60 image.jpg -o image.webp
141+
```
142+
143+
The quality value `60` usually yields good results. For very good quality, you can use the value `80`.
144+
145+
146+
### Asciinema casts
147+
148+
[Asciinema](https://asciinema.org/) allows you to record terminal sessions using a lightweight text-based format.
149+
150+
If you want to use an asciinema cast in your article, see [asciinema casts](../asciinema-casts "asciinema casts").
95151

96152

97153
### Code blocks with tabs
@@ -144,22 +200,42 @@ You can also easily **indent a tabbed code block**, by preceding the `tabs` and
144200

145201
[indented-tabbed-code-block]: https://github.com/espressif/developer-portal/blob/bfc7ee90bfc434bd1b1577a0fd1635a3923391d1/content/blog/build-embedded-swift-application-for-esp32c6/index.md?plain=1#L49-L65
146202

203+
147204
### Diagrams as code
148205

149206
A number of [Diagrams as code](https://gohugo.io/content-management/diagrams/) formats are supported, including [Mermaid](https://mermaid.js.org/).
150207

151208
For example, a Mermaid diagram is used on [this page](../contrib-workflow "Contribution workflow") (see also the [raw version][contrib-workflow-raw]).
152209

153-
[contrib-workflow-raw]: https://github.com/espressif/developer-portal/blob/main/content/pages/contribution-guide/content-contrib-workflow/index.md?plain=1#L16-L41
210+
[contrib-workflow-raw]: https://github.com/espressif/developer-portal/blob/main/content/pages/contribution-guide/contrib-workflow/index.md?plain=1#L16-L41
154211

155-
### Asciinema casts
156212

157-
[asciinema casts](../asciinema-casts "asciinema casts")
213+
### Video
158214

215+
To embed a YouTube video in your article, use the [Hugo shortcode](https://gohugo.io/content-management/shortcodes/#youtube).
159216

160-
### Video
161217

162-
Youtube videos using [Hugo shortcodes](https://gohugo.io/content-management/shortcodes/#youtube)
218+
## Use pre-commit
219+
220+
This project has a [pre-commit][] hook that can perform the following checks:
221+
222+
- Enforce coding standards and best practices in the project's codebase
223+
- Check links using [lychee][]
224+
- **Important**: this check requires Docker as a dependency, please make sure it is installed
225+
226+
[pre-commit]: https://pre-commit.com/
227+
[lychee]: https://github.com/lycheeverse/lychee
228+
229+
If you want to use pre-commit, in your project folder, run:
230+
231+
```sh
232+
# Install requirements
233+
pip install -r requirements.txt
234+
# Set up git hook scripts
235+
pre-commit install
236+
# Remove git hook scripts (if not needed)
237+
pre-commit uninstall
238+
```
163239

164240

165241
## Ask for review

0 commit comments

Comments
 (0)