Merge lp:~mvo/snappy/snappy-docs-mdlint into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Michael Vogt
Status: Merged
Approved by: John Lenton
Approved revision: 467
Merged at revision: 466
Proposed branch: lp:~mvo/snappy/snappy-docs-mdlint
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 322 lines (+134/-93)
7 files modified
debian/control (+3/-1)
docs/hashes.md (+8/-8)
docs/meta.md (+61/-61)
docs/package-names.md (+1/-1)
docs/security.md (+22/-22)
mdlint.py (+36/-0)
run-checks (+3/-0)
To merge this branch: bzr merge lp:~mvo/snappy/snappy-docs-mdlint
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
Review via email: mp+259490@code.launchpad.net

Commit message

Add simple markdown lint to ensure the tables are correctly rendered and run as part of "run-checks.sh"

Description of the change

This is mostly a RFC, this branch may be overkill and too simplistic at the same time (how often do you have that!).

When looking at https://code.launchpad.net/~stephen-stewart/snappy/docs-tidy-up-package-metadata/+merge/259050 I was wondering if we should have a mdlint and run it as part of run-checks. This branch does that. The code that does the lint is very simplistic though.

To post a comment you must log in.
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

This looks good, I wonder if we settle with markdown(django) that maybe we should move the rst doc to md as well, in a different MP that is.

I guess there is no such thing as a markdown(django) linter, this should do for this case. I added a teeny comment though.

Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks Sergio, I think this makes sense and I added exit code handling now.

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-05-08 19:42:00 +0000
3+++ debian/control 2015-05-19 14:28:51 +0000
4@@ -14,7 +14,9 @@
5 golang-gocheck-dev,
6 golang-goconfigparser-dev,
7 golang-pb-dev,
8- golang-yaml.v2-dev
9+ golang-yaml.v2-dev,
10+ python3,
11+ python3-markdown
12 Standards-Version: 3.9.6
13 Homepage: https://launchpad.net/snappy
14 Vcs-Browser: http://bazaar.launchpad.net/~snappy-dev/snappy/trunk/files
15
16=== modified file 'docs/hashes.md'
17--- docs/hashes.md 2015-03-26 20:35:57 +0000
18+++ docs/hashes.md 2015-05-19 14:28:51 +0000
19@@ -6,17 +6,17 @@
20 ## Format
21
22 The yaml looks like this:
23- * archive-sha512: the hexdigest of the data.tar.gz
24+* archive-sha512: the hexdigest of the data.tar.gz
25
26 Then a list of files/directories/symlinks in the tar that are
27 described with:
28- * name: the full path in the archive
29- * mode: First char is the type "f" for file, "d" for dir, "l" for
30- symlink. Then the unix permission bits in the form
31- rwxrwxrwx.
32- E.g. a file with mode 0644 is: "frw-r--r--"
33- * size: (applies only to files)
34- * sha512: (applies only to files) the hexdigest of the file content
35+* name: the full path in the archive
36+* mode: First char is the type "f" for file, "d" for dir, "l" for
37+ symlink. Then the unix permission bits in the form
38+ rwxrwxrwx.
39+ E.g. a file with mode 0644 is: "frw-r--r--"
40+* size: (applies only to files)
41+* sha512: (applies only to files) the hexdigest of the file content
42
43 ## Owner
44
45
46=== modified file 'docs/meta.md'
47--- docs/meta.md 2015-05-13 20:41:52 +0000
48+++ docs/meta.md 2015-05-19 14:28:51 +0000
49@@ -16,70 +16,70 @@
50 This file describes the snap package and is the most important file
51 for a snap package. The following keys are mandatory:
52
53- * `name`: the name of the snap (only `[a-z0-9][a-z0-9+.-]`)
54- * `version`: the version of the snap (only `[a-zA-Z0-9.+~-]` are allowed)
55- * `vendor`: the vendor of the snap
56+* `name`: the name of the snap (only `[a-z0-9][a-z0-9+.-]`)
57+* `version`: the version of the snap (only `[a-zA-Z0-9.+~-]` are allowed)
58+* `vendor`: the vendor of the snap
59
60 The following keys are optional:
61
62- * `icon`: a SVG icon for the snap that is displayed in the store
63- * `explicit-license-agreement`: set to `Y` if the user needs to accept a
64- special `meta/license.txt` before the snap can be installed
65- * `license-version`: a string that, when it changes and
66- `explicit-license-agreement` is `Y`, prompts the user to accept the
67- license again.
68- * `type`: (optional) the type of the snap, can be:
69- * `app` - the default if empty
70- * `oem` - a special snap that OEMs can use to customize snappy for
71- their hardware
72- * `framework` - a specialized snap that extends the system that other
73- snaps may use
74-
75- * `architectures`: (optional) a yaml list of supported architectures
76- `["all"]` if empty
77- * `frameworks`: a list of the frameworks the snap needs as dependencies
78-
79- * `services`: the servies (daemons) that the snap provides
80- * `name`: (required) name of the service (only `[a-zA-Z0-9+.-]`)
81- * `description`: (required) description of the service
82- * `start`: (required) the command to start the service
83- * `stop`: (optional) the command to stop the service
84- * `stop-timeout`: (optional) the time in seconds to wait for the
85- service to stop
86- * `poststop`: a command that runs after the service has stopped
87- * `caps`: (optional) list of additional security policies to add.
88- See `security.md` for details
89- * `security-template`: (optional) alternate security template to use
90- instead of `default`. See `security.md` for details
91- * `security-override`: (optional) high level overrides to use when
92- `security-template` and `caps` are not
93- sufficient. See security.md for details
94- * `security-policy`: (optional) hand-crafted low-level raw security
95- policy to use instead of using default
96- template-based security policy. See
97- security.md for details
98- * `ports`: (optional) define what ports the service will work
99- * `internal`: the ports the service is going to connect to
100- * `tagname`: a free form name
101- * `port`: (optional) number/protocol, e.g. `80/tcp`
102- * `negotiable`: (optional) Y if the app can use a different port
103- * `external`: the ports the service offer to the world
104- * `tagname`: a free form name, some names have meaning like "ui"
105- * `port`: (optional) see above
106- * `negotiable`: (optional) see above
107- * `bus-name`: (optional) message bus connection name for the service.
108- May only be specified for snaps of 'type: framework' (see above). See
109- frameworks.md for details.
110-
111- * `binaries`: the binaries (executables) that the snap provides
112- * `name`: (required) the name of the binary, the user will be able to
113- call it as $name.$pkgname (only `[a-zA-Z0-9+.-]`)
114- * `exec`: the program that gets executed (can be omited if name points
115- to a binary already)
116- * `caps`: (optional) see entry in `services` (above)
117- * `security-template`: (optional) see entry in `services` (above)
118- * `security-override`: (optional) see entry in `services` (above)
119- * `security-policy`: (optional) see entry in `services` (above)
120+* `icon`: a SVG icon for the snap that is displayed in the store
121+* `explicit-license-agreement`: set to `Y` if the user needs to accept a
122+ special `meta/license.txt` before the snap can be installed
123+* `license-version`: a string that, when it changes and
124+ `explicit-license-agreement` is `Y`, prompts the user to accept the
125+ license again.
126+* `type`: (optional) the type of the snap, can be:
127+ * `app` - the default if empty
128+ * `oem` - a special snap that OEMs can use to customize snappy for
129+ their hardware
130+ * `framework` - a specialized snap that extends the system that other
131+ snaps may use
132+
133+* `architectures`: (optional) a yaml list of supported architectures
134+ `["all"]` if empty
135+* `frameworks`: a list of the frameworks the snap needs as dependencies
136+
137+* `services`: the servies (daemons) that the snap provides
138+ * `name`: (required) name of the service (only `[a-zA-Z0-9+.-]`)
139+ * `description`: (required) description of the service
140+ * `start`: (required) the command to start the service
141+ * `stop`: (optional) the command to stop the service
142+ * `stop-timeout`: (optional) the time in seconds to wait for the
143+ service to stop
144+ * `poststop`: a command that runs after the service has stopped
145+ * `caps`: (optional) list of additional security policies to add.
146+ See `security.md` for details
147+ * `security-template`: (optional) alternate security template to use
148+ instead of `default`. See `security.md` for details
149+ * `security-override`: (optional) high level overrides to use when
150+ `security-template` and `caps` are not
151+ sufficient. See security.md for details
152+ * `security-policy`: (optional) hand-crafted low-level raw security
153+ policy to use instead of using default
154+ template-based security policy. See
155+ security.md for details
156+ * `ports`: (optional) define what ports the service will work
157+ * `internal`: the ports the service is going to connect to
158+ * `tagname`: a free form name
159+ * `port`: (optional) number/protocol, e.g. `80/tcp`
160+ * `negotiable`: (optional) Y if the app can use a different port
161+ * `external`: the ports the service offer to the world
162+ * `tagname`: a free form name, some names have meaning like "ui"
163+ * `port`: (optional) see above
164+ * `negotiable`: (optional) see above
165+ * `bus-name`: (optional) message bus connection name for the service.
166+ May only be specified for snaps of 'type: framework' (see above). See
167+ frameworks.md for details.
168+
169+* `binaries`: the binaries (executables) that the snap provides
170+ * `name`: (required) the name of the binary, the user will be able to
171+ call it as $name.$pkgname (only `[a-zA-Z0-9+.-]`)
172+ * `exec`: the program that gets executed (can be omited if name points
173+ to a binary already)
174+ * `caps`: (optional) see entry in `services` (above)
175+ * `security-template`: (optional) see entry in `services` (above)
176+ * `security-override`: (optional) see entry in `services` (above)
177+ * `security-policy`: (optional) see entry in `services` (above)
178
179 ## license.txt
180
181
182=== modified file 'docs/package-names.md'
183--- docs/package-names.md 2015-04-15 22:03:57 +0000
184+++ docs/package-names.md 2015-05-19 14:28:51 +0000
185@@ -135,4 +135,4 @@
186 becomes the gaming engine, you will need to be pushed out to a different name.
187
188 ## Open questions
189- * Must finalize what the `APP_ID` is going to be (composed? no devname? etc)
190+* Must finalize what the `APP_ID` is going to be (composed? no devname? etc)
191
192=== modified file 'docs/security.md'
193--- docs/security.md 2015-05-12 15:32:03 +0000
194+++ docs/security.md 2015-05-19 14:28:51 +0000
195@@ -81,14 +81,14 @@
196 Specify `caps: []` to indicate no additional `caps`. When `caps` and
197 `security-template` are not specified, `caps` defaults to client networking.
198 Not compatible with `security-override` or `security-policy`.
199- * AppArmor access is deny by default and apps are restricted to their
200- app-specific directories, libraries, etc (enforcing ro, rw, etc).
201- Additional access beyond what is allowed by the declared `security-template`
202- is declared via this option
203- * seccomp is deny by default. Enough safe syscalls are allowed so that apps
204- using the declared `security-template` should work. Additional access
205- beyond what is allowed by the `security-template` is declared via this
206- option
207+ * AppArmor access is deny by default and apps are restricted to
208+ their app-specific directories, libraries, etc (enforcing ro,
209+ rw, etc). Additional access beyond what is allowed by the
210+ declared `security-template` is declared via this option
211+ * seccomp is deny by default. Enough safe syscalls are allowed so
212+ that apps using the declared `security-template` should
213+ work. Additional access beyond what is allowed by the
214+ `security-template` is declared via this option
215 * `security-template`: (optional) alternate security template to use instead of
216 `default`. When specified without `caps`, `caps` defaults to being empty. Not
217 compatible with `security-override` or `security-policy`.
218@@ -97,13 +97,13 @@
219 [advanced usage](https://wiki.ubuntu.com/SecurityTeam/Specifications/SnappyConfinement)
220 for details. Not compatible with `caps`, `security-template` or
221 `security-policy`
222- * `apparmor: path/to/security.override`
223- * `seccomp: path/to/filter.override`
224+ * `apparmor: path/to/security.override`
225+ * `seccomp: path/to/filter.override`
226 * `security-policy`: (optional) hand-crafted low-level raw security policy to
227 use instead of using default template-based security policy. Not compatible
228 with `caps`, `security-template` or `security-override`.
229- * `apparmor: path/to/profile`
230- * `seccomp: path/to/filter`
231+ * `apparmor: path/to/profile`
232+ * `seccomp: path/to/filter`
233
234 Eg, consider the following:
235
236@@ -199,22 +199,22 @@
237 The following is planned:
238
239 * launcher:
240- * utilize syscall argument filtering
241- * setup additional cgroups (tag network traffic, memory)
242- * setup iptables using cgroup tags (for internal app access)
243- * drop privileges to uid of service
244+ * utilize syscall argument filtering
245+ * setup additional cgroups (tag network traffic, memory)
246+ * setup iptables using cgroup tags (for internal app access)
247+ * drop privileges to uid of service
248 * fine-grained network mediation via AppArmor
249 * `sockets`: (optional) `AF_UNIX` abstract socket definition for coordinated
250 snap communications. Abstract sockets will be namespaced and yaml is such
251 that (client) apps wanting to use the socket don't have to declare anything
252 extra, but they don't have access unless the (server) binary declaring the
253 socket says that app is ok).
254- * `names`: (optional) list of abstract socket names (`<name>_<binaryname>` is
255- prepended)
256- * `allowed-clients`: `<name>.<namespace>` or `<name>.<namespace>_<binaryname>`
257- (ie, omit version and `binaryname` to allow all from snap
258- `<name>.<namespace>` or omit version to allow only `binaryname` from snap
259- `<name>`)
260+ * `names`: (optional) list of abstract socket names
261+ (`<name>_<binaryname>` is prepended)
262+ * `allowed-clients`: `<name>.<namespace>` or
263+ `<name>.<namespace>_<binaryname>` (ie, omit version and
264+ `binaryname` to allow all from snap `<name>.<namespace>` or omit
265+ version to allow only `binaryname` from snap `<name>`)
266
267 Eg:
268
269
270=== added file 'mdlint.py'
271--- mdlint.py 1970-01-01 00:00:00 +0000
272+++ mdlint.py 2015-05-19 14:28:51 +0000
273@@ -0,0 +1,36 @@
274+#!/usr/bin/python
275+#
276+# see http://daringfireball.net/projects/markdown/syntax
277+# for the "canonical" reference
278+#
279+# We support django-markdown which uses python-markdown, see:
280+# http://pythonhosted.org/Markdown/
281+
282+import sys
283+
284+
285+def lint_li(fname, text):
286+ """Ensure that the list-items are multiplies of 4"""
287+ is_clean = True
288+ for i, line in enumerate(text.splitlines()):
289+ if line.lstrip().startswith("*") and line.index("*") % 4 != 0:
290+ print("%s: line %i list has non-4 spaces indent" % (fname, i))
291+ is_clean = False
292+ return is_clean
293+
294+
295+def lint(md_files):
296+ """lint all md files"""
297+ all_clean = True
298+ for md in md_files:
299+ with open(md) as f:
300+ buf = f.read()
301+ for fname, func in globals().items():
302+ if fname.startswith("lint_"):
303+ all_clean &= func(md, buf)
304+ return all_clean
305+
306+
307+if __name__ == "__main__":
308+ if not lint(sys.argv):
309+ sys.exit(1)
310
311=== modified file 'run-checks'
312--- run-checks 2015-03-27 18:35:24 +0000
313+++ run-checks 2015-05-19 14:28:51 +0000
314@@ -8,6 +8,9 @@
315 goctest="go test"
316 fi
317
318+echo Checking docs
319+./mdlint.py docs/*.md
320+
321 echo Checking formatting
322 fmt=$(gofmt -l .)
323

Subscribers

People subscribed via source and target branches