Skip to content

Commit 4f537c6

Browse files
authored
Merge pull request scop#676 from scop/docs/asciidoc
asciidoc test and fixes
2 parents 2b6785d + 9ac8c79 commit 4f537c6

File tree

5 files changed

+63
-85
lines changed

5 files changed

+63
-85
lines changed

.pre-commit-config.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,23 @@ repos:
116116
- scan
117117
exclude: ^CHANGELOG\.md$
118118

119+
- repo: local
120+
hooks:
121+
- id: asciidoctor
122+
name: asciidoctor
123+
language: docker_image
124+
entry: asciidoctor/docker-asciidoctor:1.15 asciidoctor
125+
args:
126+
- --out-file
127+
- /dev/null
128+
- --failure-level
129+
- WARN
130+
- --doctype
131+
- book
132+
- doc/main.txt
133+
pass_filenames: false
134+
files: ^doc/.*\.txt$
135+
119136
- repo: https://github.com/pre-commit/pre-commit-hooks
120137
rev: v4.0.1
121138
hooks:

doc/bash_completion.txt

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
Bash completion
2-
===============
1+
= Bash completion
32

4-
Configuration files
5-
-------------------
3+
== Configuration files
64

75
*$BASH_COMPLETION_USER_FILE*::
86
Sourced late by bash_completion, pretty much after everything else.
@@ -16,8 +14,7 @@ Configuration files
1614
below. If `$XDG_CONFIG_HOME` is unset or null, `~/.config` is
1715
used instead of it.
1816

19-
Environment variables
20-
---------------------
17+
== Environment variables
2118

2219
*BASH_COMPLETION_COMPAT_DIR*::
2320
Directory for pre-dynamic loading era (pre-2.0) backwards compatibility

doc/main.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
Bash-completion
2-
===============
1+
= Bash-completion
2+
33
Freddy Vulto (FVu)
44
v1.0, Mar 2009
55

6-
Preface
7-
=======
6+
[preface]
7+
= Preface
8+
89
Bash completion extends bashs standard completion behavior to achieve
910
complex command lines with just a few keystrokes. This project was
1011
conceived to produce programmable completion routines for the most

doc/styleguide.txt

+21-36
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
Coding Style Guide
2-
==================
1+
= Coding Style Guide
2+
3+
== Introduction
34

4-
Introduction
5-
------------
65
This document attempts to explain the basic styles and patterns that
76
are used in the bash completion. New code should try to conform to
87
these standards so that it is as easy to maintain as existing code.
@@ -14,43 +13,38 @@ codebase, who are in the process of getting their code reviewed.
1413
Before getting a review, please read over this document and make
1514
sure your code conforms to the recommendations here.
1615

17-
Indentation
18-
-----------
16+
== Indentation
17+
1918
Indent step should be 4 spaces, no tabs.
2019

21-
Globbing in case labels
22-
-----------------------
20+
== Globbing in case labels
2321

2422
Avoid "fancy" globbing in case labels, just use traditional style when
2523
possible. For example, do "--foo|--bar)" instead of "--@(foo|bar))".
2624
Rationale: the former is easier to read, often easier to grep, and
2725
doesn't confuse editors as bad as the latter, and is concise enough.
2826

29-
[[ ]] vs [ ]
30-
----------------
27+
== [[ ]] vs [ ]
3128

3229
Always use [[ ]] instead of [ ]. Rationale: the former is less error
3330
prone, more featureful, and slightly faster.
3431

35-
Line wrapping
36-
-------------
32+
== Line wrapping
3733

3834
Try to wrap lines at 79 characters. Never go past this limit, unless
3935
you absolutely need to (example: a long sed regular expression, or the
4036
like). This also holds true for the documentation and the testsuite.
4137
Other files, like ChangeLog, or COPYING, are exempt from this rule.
4238

43-
$(...) vs \`...`
44-
----------------
39+
== $(...) vs \`...`
4540

4641
When you need to do some code substitution in your completion script,
4742
you *MUST* use the $(...) construct, rather than the \`...`. The former
4843
is preferable because anyone, with any keyboard layout, is able to
4944
type it. Backticks aren't always available, without doing strange
5045
key combinations.
5146

52-
-o filenames
53-
------------
47+
== -o filenames
5448

5549
As a rule of thumb, do not use "complete -o filenames". Doing it makes
5650
it take effect for all completions from the affected function, which
@@ -61,8 +55,7 @@ need that kind of processing (e.g. file and command names). The
6155
_filedir and _filedir_xspec helpers do this automatically whenever
6256
they return some completions.
6357

64-
`[[ ${COMPREPLY-} == *= ]] && compopt -o nospace`
65-
-------------------------------------------------
58+
== `[[ ${COMPREPLY-} == *= ]] && compopt -o nospace`
6659

6760
The above is functionally a shorthand for:
6861

@@ -75,8 +68,7 @@ appended after the equal sign. Calling compopt -o nospace makes sense
7568
in case completion actually occurs: when only one completion is
7669
available in COMPREPLY.
7770

78-
`$split && return`
79-
------------------
71+
== `$split && return`
8072

8173
Should be used in completions using the -s flag of _init_completion,
8274
or other similar cases where _split_longopt has been invoked, after
@@ -95,31 +87,27 @@ explicitly handled (non-completed) in the $prev handling block because
9587
--foo=bar options can often be written without the equals sign, and in
9688
that case the long option splitting does not occur.
9789

98-
Use arithmetic evaluation
99-
-------------------------
90+
== Use arithmetic evaluation
10091

10192
When dealing with numeric data, take advantage of arithmetic evaluation.
10293
In essence, use (( ... )) whenever it can replace [[ ... ]] because the
10394
syntax is more readable; no need for $-prefixes, numeric comparison etc
10495
operators are more familiar and easier on the eye.
10596

106-
Array subscript access
107-
----------------------
97+
== Array subscript access
10898

10999
Array subscripts are arithmetic expressions, take advantage of that.
110100
E.g. write ${foo[bar]}, not ${foo[$bar]}, and similarly ${foo[bar+1]}
111101
vs ${foo[((bar+1))]} or ${foo[$((bar+1))]}, ${foo[--i]} vs ${foo[((--i))]}.
112102

113-
Loop variable names
114-
-------------------
103+
== Loop variable names
115104

116105
Use i, j, k for loop-local indices; n and m for lengths; some other descriptive
117106
name typically based on array name but in singular when looping over actual
118107
values. If an index or value is to be accessed later on instead of being just
119108
locally for looping, use a more descriptive and specific name for it.
120109

121-
Function names
122-
--------------
110+
== Function names
123111

124112
Use the _comp_ prefix for all function names, and _comp_cmd_ for functions
125113
defined in per command completion files and not anywhere else. Prefixing with
@@ -133,16 +121,13 @@ This is due to backwards compatibility reasons, but all functions introduced
133121
after version 2.11 should follow this name prefix rule.
134122

135123
/////////////////////////////////////////
136-
case/esac vs if
137-
---------------
138124

139-
quoting
140-
-------
125+
== case/esac vs if
126+
127+
== quoting
141128

142-
awk vs cut for simple cases
143-
---------------------------
129+
== awk vs cut for simple cases
144130

145-
variable naming
146-
---------------
131+
== variable naming
147132

148133
/////////////////////////////////////////

doc/testing.txt

+17-39
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
Automated testing
2-
=================
1+
= Automated testing
2+
3+
== Introduction
34

4-
Introduction
5-
------------
65
The bash-completion package contains an automated test suite. Running the
76
tests should help verifying that bash-completion works as expected. The tests
87
are also very helpful in uncovering software regressions at an early stage.
98

109
The test suite is written in Python, using https://pytest.org/[pytest]
1110
and https://pexpect.readthedocs.io/[pexpect].
1211

13-
14-
Coding Style Guide
15-
------------------
12+
== Coding Style Guide
1613

1714
For the Python part, all of it is formatted using
1815
https://github.com/ambv/black[Black], and we also run
1916
https://flake8.pycqa.org/[Flake8] on it.
2017

21-
22-
Installing dependencies
23-
-----------------------
18+
== Installing dependencies
2419

2520
Installing dependencies should be easy using your local package manager or
2621
`pip`. Python 3.6 or newer is required, and the rest of the Python package
@@ -30,9 +25,7 @@ this file can be fed directly to it, e.g. like:
3025
pip install -r test/requirements.txt
3126
------------------------------------
3227

33-
34-
Debian/Ubuntu
35-
~~~~~~~~~~~~~
28+
=== Debian/Ubuntu
3629

3730
On Debian/Ubuntu you can use `apt-get`:
3831
-------------
@@ -42,8 +35,7 @@ This should also install the necessary dependencies. Only Debian testing
4235
(buster) and Ubuntu 18.10 (cosmic) and later have an appropriate version
4336
of pytest in the repositories.
4437

45-
Fedora/RHEL/CentOS
46-
~~~~~~~~~~~~~~~~~~
38+
=== Fedora/RHEL/CentOS
4739

4840
On Fedora and RHEL/CentOS (with EPEL) you can try `yum` or `dnf`:
4941
-------------
@@ -52,17 +44,12 @@ sudo yum install python3-pytest python3-pexpect
5244
This should also install the necessary dependencies. At time of writing, only
5345
Fedora 29 comes with recent enough pytest.
5446

55-
56-
57-
Structure
58-
---------
47+
== Structure
5948

6049
Tests are in the `t/` subdirectory, with `t/test_\*.py` being completion
6150
tests, and `t/unit/test_unit_\*.py` unit tests.
6251

63-
64-
Running the tests
65-
-----------------
52+
== Running the tests
6653

6754
Tests are run by calling `pytest` on the desired test directories or
6855
individual files, for example in the project root directory:
@@ -72,41 +59,32 @@ pytest test/t
7259

7360
See `test/docker/entrypoint.sh` for how and what we run and test in CI.
7461

75-
76-
Specifying bash binary
77-
~~~~~~~~~~~~~~~~~~~~~~
62+
=== Specifying bash binary
7863

7964
The test suite standard uses `bash` as found in PATH. Export the
8065
`bashcomp_bash` environment variable with a path to another bash executable if
8166
you want to test against something else.
8267

68+
== Maintenance
8369

84-
Maintenance
85-
-----------
86-
87-
88-
Adding a completion test
89-
~~~~~~~~~~~~~~~~~~~~~~~~
70+
=== Adding a completion test
9071

9172
You can run `cd test && ./generate cmd` to add a test for the `cmd`
9273
command. Additional arguments will be passed to the first generated test case.
9374
This will add the `test/t/test_cmd.py` file with a very basic test, and add it
9475
to `test/t/Makefile.am`. Add additional tests to the generated file.
9576

96-
Rationale
97-
---------
77+
== Rationale
9878

79+
=== Naming conventions
9980

100-
Naming conventions
101-
~~~~~~~~~~~~~~~~~~
81+
==== Test suite or testsuite
10282

103-
Test suite or testsuite
104-
^^^^^^^^^^^^^^^^^^^^^^^
10583
The primary Wikipedia page is called
10684
https://en.wikipedia.org/wiki/Test_suite[test suite] and not testsuite, so
10785
that's what this document sticks to.
10886

109-
script/generate
110-
^^^^^^^^^^^^^^^
87+
==== script/generate
88+
11189
The name and location of this code generation script come from Ruby on Rails'
11290
https://en.wikibooks.org/wiki/Ruby_on_Rails/Tools/Generators[script/generate].

0 commit comments

Comments
 (0)