Skip to content

Commit 9b0081c

Browse files
committed
Add documentation about the website.
- Add a README with details on the differences with the official documentation, and instructions on how to use the generator. - The front page of each FFmpeg version now includes the list of differences. Its content is taken from the README.md file.
1 parent 8dd48ab commit 9b0081c

File tree

12 files changed

+399
-125
lines changed

12 files changed

+399
-125
lines changed

.github/readme/badge.svg

+22
Loading

.nix/gemset.nix

+41-20
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
{
2+
bigdecimal = {
3+
groups = [ "default" ];
4+
platforms = [ ];
5+
source = {
6+
remotes = [ "https://rubygems.org" ];
7+
sha256 = "1gi7zqgmqwi5lizggs1jhc3zlwaqayy9rx2ah80sxy24bbnng558";
8+
type = "gem";
9+
};
10+
version = "3.1.8";
11+
};
212
concurrent-ruby = {
313
groups = [ "default" ];
414
platforms = [ ];
515
source = {
616
remotes = [ "https://rubygems.org" ];
7-
sha256 = "1qh1b14jwbbj242klkyz5fc7npd4j0mvndz62gajhvl1l3wd7zc2";
17+
sha256 = "0chwfdq2a6kbj6xz9l6zrdfnyghnh32si82la1dnpa5h75ir5anl";
818
type = "gem";
919
};
10-
version = "1.2.3";
20+
version = "1.3.4";
1121
};
1222
google-protobuf = {
23+
dependencies = [ "bigdecimal" "rake" ];
1324
groups = [ "default" ];
1425
platforms = [ ];
1526
source = {
1627
remotes = [ "https://rubygems.org" ];
17-
sha256 = "1mnxzcq8kmyfb9bkzqnp019d1hx1vprip3yzdkkha6b3qz5rgg9r";
28+
sha256 = "1d99vyhmyp2n5zd0qmfymzwbcn71dbnwwvc0m4z14msjb7b8dvf0";
1829
type = "gem";
1930
};
20-
version = "3.25.3";
31+
version = "4.28.3";
2132
};
2233
haml = {
2334
dependencies = [ "temple" "thor" "tilt" ];
@@ -35,62 +46,72 @@
3546
platforms = [ ];
3647
source = {
3748
remotes = [ "https://rubygems.org" ];
38-
sha256 = "1kl9c3kdchjabrihdqfmcplk3lq4cw1rr9f378y6q22qwy5dndvs";
49+
sha256 = "1q1f2sdw3y3y9mnym9dhjgsjr72sq975cfg5c4yx7gwv8nmzbvhk";
3950
type = "gem";
4051
};
41-
version = "2.8.5";
52+
version = "2.8.7";
4253
};
4354
nokogiri = {
4455
dependencies = [ "mini_portile2" "racc" ];
4556
groups = [ "default" ];
4657
platforms = [ ];
4758
source = {
4859
remotes = [ "https://rubygems.org" ];
49-
sha256 = "173zavvxlwyi48lfskk48wcrdbkvjlhjhvy4jpcrfx72rpjjx4k8";
60+
sha256 = "15gysw8rassqgdq3kwgl4mhqmrgh7nk2qvrcqp4ijyqazgywn6gq";
5061
type = "gem";
5162
};
52-
version = "1.16.2";
63+
version = "1.16.7";
5364
};
5465
racc = {
5566
groups = [ "default" ];
5667
platforms = [ ];
5768
source = {
5869
remotes = [ "https://rubygems.org" ];
59-
sha256 = "01b9662zd2x9bp4rdjfid07h09zxj7kvn7f5fghbqhzc625ap1dp";
70+
sha256 = "0byn0c9nkahsl93y9ln5bysq4j31q8xkf2ws42swighxd4lnjzsa";
6071
type = "gem";
6172
};
62-
version = "1.7.3";
73+
version = "1.8.1";
6374
};
6475
rake = {
6576
groups = [ "default" ];
6677
platforms = [ ];
6778
source = {
6879
remotes = [ "https://rubygems.org" ];
69-
sha256 = "1ilr853hawi09626axx0mps4rkkmxcs54mapz9jnqvpnlwd3wsmy";
80+
sha256 = "17850wcwkgi30p7yqh60960ypn7yibacjjha0av78zaxwvd3ijs6";
81+
type = "gem";
82+
};
83+
version = "13.2.1";
84+
};
85+
redcarpet = {
86+
groups = [ "default" ];
87+
platforms = [ ];
88+
source = {
89+
remotes = [ "https://rubygems.org" ];
90+
sha256 = "1sg9sbf9pm91l7lac7fs4silabyn0vflxwaa2x3lrzsm0ff8ilca";
7091
type = "gem";
7192
};
72-
version = "13.1.0";
93+
version = "3.6.0";
7394
};
7495
rouge = {
7596
groups = [ "default" ];
7697
platforms = [ ];
7798
source = {
7899
remotes = [ "https://rubygems.org" ];
79-
sha256 = "1fkfa0iq3r9b0zzrxpxha17avmyzci3kidzmfbf6fd1279mndpb0";
100+
sha256 = "0r0b48945hakgy0y7lg6h1bb7pkfz8jqd0r6777f80ij3sansvbs";
80101
type = "gem";
81102
};
82-
version = "4.2.0";
103+
version = "4.4.0";
83104
};
84105
sass-embedded = {
85106
dependencies = [ "google-protobuf" "rake" ];
86107
groups = [ "default" ];
87108
platforms = [ ];
88109
source = {
89110
remotes = [ "https://rubygems.org" ];
90-
sha256 = "1ccqqkmicqs2nbawyknb17qfafwqq0k6jxibcm86vqd1jp185pxa";
111+
sha256 = "1xiszsk8j3vvj6dxrkvx7kn8adh24dq8kxxa6wlz8ns6mb3l2dib";
91112
type = "gem";
92113
};
93-
version = "1.71.1";
114+
version = "1.80.6";
94115
};
95116
temple = {
96117
groups = [ "default" ];
@@ -107,19 +128,19 @@
107128
platforms = [ ];
108129
source = {
109130
remotes = [ "https://rubygems.org" ];
110-
sha256 = "1vq1fjp45az9hfp6fxljhdrkv75cvbab1jfrwcw738pnsiqk8zps";
131+
sha256 = "1nmymd86a0vb39pzj2cwv57avdrl6pl3lf5bsz58q594kqxjkw7f";
111132
type = "gem";
112133
};
113-
version = "1.3.1";
134+
version = "1.3.2";
114135
};
115136
tilt = {
116137
groups = [ "default" ];
117138
platforms = [ ];
118139
source = {
119140
remotes = [ "https://rubygems.org" ];
120-
sha256 = "0p3l7v619hwfi781l3r7ypyv1l8hivp09r18kmkn6g11c4yr1pc2";
141+
sha256 = "0kds7wkxmb038cwp6ravnwn8k65ixc68wpm8j5jx5bhx8ndg4x6z";
121142
type = "gem";
122143
};
123-
version = "2.3.0";
144+
version = "2.4.0";
124145
};
125146
}

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ gem "nokogiri", "~> 1"
55
gem "rouge", "~> 4.1"
66
gem "sass-embedded", "~> 1"
77
gem "concurrent-ruby", "~> 1.2"
8+
gem "redcarpet", "~> 3.6"

Gemfile.lock

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
concurrent-ruby (1.2.3)
5-
google-protobuf (3.25.3)
4+
bigdecimal (3.1.8)
5+
concurrent-ruby (1.3.4)
6+
google-protobuf (4.28.3)
7+
bigdecimal
8+
rake (>= 13)
69
haml (6.3.0)
710
temple (>= 0.8.2)
811
thor
912
tilt
10-
mini_portile2 (2.8.5)
11-
nokogiri (1.16.2)
13+
mini_portile2 (2.8.7)
14+
nokogiri (1.16.7)
1215
mini_portile2 (~> 2.8.2)
1316
racc (~> 1.4)
14-
racc (1.7.3)
15-
rake (13.1.0)
16-
rouge (4.2.0)
17-
sass-embedded (1.71.1)
18-
google-protobuf (~> 3.25)
19-
rake (>= 13.0.0)
17+
racc (1.8.1)
18+
rake (13.2.1)
19+
redcarpet (3.6.0)
20+
rouge (4.4.0)
21+
sass-embedded (1.80.6)
22+
google-protobuf (~> 4.28)
23+
rake (>= 13)
2024
temple (0.10.3)
21-
thor (1.3.1)
22-
tilt (2.3.0)
25+
thor (1.3.2)
26+
tilt (2.4.0)
2327

2428
PLATFORMS
2529
ruby
@@ -28,8 +32,9 @@ DEPENDENCIES
2832
concurrent-ruby (~> 1.2)
2933
haml (~> 6)
3034
nokogiri (~> 1)
35+
redcarpet (~> 3.6)
3136
rouge (~> 4.1)
3237
sass-embedded (~> 1)
3338

3439
BUNDLED WITH
35-
2.5.5
40+
2.5.16

README.md

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# FFmpeg Filters Documentation
2+
3+
The tool in this repository builds an alternative presentation of the
4+
[official documentation for FFmpeg filters][offdocs]. It aims to be easier
5+
to read and easier to navigate.
6+
7+
[![Open Website](.github/readme/badge.svg)][website]
8+
9+
<!-- differences -->
10+
11+
## Differences with the Official Documentation
12+
13+
* Each filter has its own dedicated page.
14+
15+
* Filters are organized into groups (like *Filters / Audio*, or
16+
*Sources / Multimedia*).
17+
18+
The groups are guessed from the section headers in the official
19+
documentation.
20+
21+
* All pages have a search box to jump to another filter.
22+
23+
It can be focused by pressing the key <kbd>/</kbd>, and then use arrows
24+
(<kbd>↓</kbd>, <kbd>↑</kbd>) to select one of the results.
25+
26+
The filter's description in the search results is the first sentence of its
27+
documentation.
28+
29+
* Many code snippets are rendered with syntax highlighting.
30+
31+
<!-- [highlight] This is an example from the filter:overlay filter:
32+
33+
ffmpeg -i left.avi -i right.avi -filter_complex "
34+
nullsrc=size=200x100 [background];
35+
[0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
36+
[1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
37+
[background][left] overlay=shortest=1 [background+left];
38+
[background+left][right] overlay=shortest=1:x=100 [left+right]
39+
"
40+
-->
41+
42+
The highlighting is inferred from the content, so it may not work in some
43+
cases. The official documentation does not specify the language in which the
44+
snippets are written.
45+
46+
* Responsive design for smaller screens.
47+
48+
* Dark and light themes.
49+
50+
* Documentation for all _major.minor_ versions, under *Other Vers.* in the sidebar.
51+
52+
This is helpful when you have to use an older version of FFmpeg.
53+
54+
* The *Version Matrix* shows which filters are available in each FFmpeg version.
55+
56+
<!-- end differences -->
57+
58+
## Usage
59+
60+
The documentation can be [read in GitHub Pages][website], and it is possible to
61+
build it locally.
62+
63+
### Nix Flakes
64+
65+
The recommended way to run the generator is with [`nix run`][nix-run]:
66+
67+
```console
68+
$ nix run github:ayosec/ffmpeg-filters-docs
69+
```
70+
71+
The tool accepts some command-line arguments (see `--help`). For example, to
72+
build only the documentation for FFmpeg 7.1 in the path `/tmp/ffdocs`:
73+
74+
```console
75+
$ nix run github:ayosec/ffmpeg-filters-docs -- --versions 7.1 --output /tmp/ffdocs
76+
```
77+
78+
To execute the tool from a copy of this repository:
79+
80+
```console
81+
$ nix develop --command ./ffmpeg-filters-docs […]
82+
```
83+
84+
### Docker
85+
86+
A Docker image can be built with the file [`docker/Dockerfile`](./docker/Dockerfile).
87+
88+
```console
89+
$ docker build --tag ffdocs --file docker/Dockerfile .
90+
91+
$ docker run --volume /tmp/web:/tmp/web ffdocs --versions 7.1 --output /tmp/web
92+
```
93+
94+
95+
[offdocs]: https://ffmpeg.org/ffmpeg-filters.html
96+
[website]: https://ayosec.github.io/ffmpeg-filters-docs/
97+
[nix-run]: https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix3-run.html

lib/ffdocs/source_docs/html_adapter.rb

+20-14
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ def process(doc)
2525
private def stylize_code_blocks(doc)
2626
doc.search("pre").each do |elem|
2727
code = elem.inner_text.strip
28-
if lexer = guess_lexer(code)
29-
formatter = Rouge::Formatters::HTMLInline.new(Rouge::Themes::Github.new)
30-
result = formatter.format(lexer.lex(code))
31-
28+
if result = SyntaxHighlight.highlight(code)
3229
# Replace <pre> with the generated HTML.
3330
elem.set_attribute("data-source", code)
3431
elem.inner_html = Nokogiri::HTML5.fragment(result)
@@ -38,16 +35,25 @@ def process(doc)
3835
doc
3936
end
4037

41-
private def guess_lexer(code)
42-
case code.lstrip
43-
when /\A__kernel/
44-
Rouge::Lexers::C.new
45-
when %r{\A#!.*/sh}, /\Aecho /
46-
Rouge::Lexers::Shell.new
47-
when /\A(-i|ffplay|ffmpeg|ffprobe)/, /\A(#.+\n)*(\.\/)?(ffplay|ffmpeg|ffprobe)/
48-
CodeExamplesLexer.new
49-
when /\A(\[(\w|-)+\]|\w+=)/, /\A\w+\[\w\]/
50-
CodeExamplesLexer.new :filtergraph
38+
module SyntaxHighlight
39+
def self.highlight(code)
40+
if lexer = guess_lexer(code)
41+
formatter = Rouge::Formatters::HTMLInline.new(Rouge::Themes::Github.new)
42+
formatter.format(lexer.lex(code))
43+
end
44+
end
45+
46+
def self.guess_lexer(code)
47+
case code.lstrip
48+
when /\A__kernel/
49+
Rouge::Lexers::C.new
50+
when %r{\A#!.*/sh}, /\Aecho /
51+
Rouge::Lexers::Shell.new
52+
when /\A(-i|ffplay|ffmpeg|ffprobe)/, /\A(#.+\n)*(\.\/)?(ffplay|ffmpeg|ffprobe)/
53+
CodeExamplesLexer.new
54+
when /\A(\[(\w|-)+\]|\w+=)/, /\A\w+\[\w\]/
55+
CodeExamplesLexer.new :filtergraph
56+
end
5157
end
5258
end
5359

0 commit comments

Comments
 (0)