Skip to content

Commit 01d5e5f

Browse files
committed
greps through kramdown warnings for missing links;
editorial tweaks/fixes to make this work; updates CONTRIBUTING.md to include link syntax requirements; Closes #379
1 parent 63600d5 commit 01d5e5f

File tree

10 files changed

+149
-17
lines changed

10 files changed

+149
-17
lines changed

.rspec

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--color
2+
--require spec_helper
3+
--format documentation

CONTRIBUTING.md

+5
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,10 @@ The _config.yml file defines various site level variables, notably the current v
6060
* Specs will use JSON and JSON-LD
6161
* Specs will use snake_case not camelCase
6262

63+
## Links
64+
65+
Links in Markdown documents must use the [reference link][reference-link] syntax, and the link id _MUST_ match this regex: `[a-zA-Z][_0-9a-zA-Z-]`, i.e., they must start with a letter, and may then contain letters, numerals, and the characters '_' and '-'.
66+
6367
[kram]: http://kramdown.gettalong.org/syntax.html
6468
[squash]: http://lmgtfy.com/?q=Squash+git+commits
69+
[reference-link]: http://kramdown.gettalong.org/syntax.html#reference-links

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
33
gem 'jekyll', '2.0.3'
44

55
group :test do
6+
gem 'rspec'
67
gem 'html-proofer'
78
end

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ Markdown Source of specifications documents
1818

1919
* Much of the site data is in the YAML files in `_data/` (e.g. member institutions, server impls, demos, etc.) make edits there.
2020
* The latest versions of the APIs are set in `_config.yml`. Change there will get pushed to `.htaccess`, `technical-details.html`, and any other links.
21+
* Always use the \[link text\]\[ref\] method of creating links. `ref` must consist only of a-zA-Z0-9_- and the first character must be a-zA-Z

source/api/annex/services/index.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,4 @@ Thanks to the members of the [IIIF][iiif-community] for their continuous engagem
234234
[icon-opt]: /img/metadata-api/optional.png "Optional"
235235
[icon-na]: /img/metadata-api/not_allowed.png "Not allowed"
236236

237-
{% for acronym in site.data.acronyms %}
238-
*[{{ acronym[0] }}]: {{ acronym[1] }}
239-
{% endfor %}
237+
{% include acronyms.md %}

source/api/presentation/2.0/index.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The following are __not__ within scope:
6363
* The discovery or selection of interesting digitized objects is not directly supported, however hooks to reference further resources are available.
6464
* Search within the object is not supported by the Presentation API; however this will be covered by a future IIIF specification.
6565

66-
Note that in the following descriptions, "[physical] object" is used to refer to a physical object that has been digitized or a born-digital compound object, and "resources" refer to the digital resources that are the result of that digitization or digital creation process.
66+
Note that in the following descriptions, "object" (or "physical object") is used to refer to a physical object that has been digitized or a born-digital compound object, and "resources" refer to the digital resources that are the result of that digitization or digital creation process.
6767

6868
## 2. Motivating Use Cases
6969

@@ -171,10 +171,10 @@ license
171171

172172
Usage:
173173
{: .usage}
174-
* A manifest _MUST_ have an id, and it _MUST_ be the http[s] URI at which the manifest is published.
174+
* A manifest _MUST_ have an id, and it _MUST_ be the http(s) URI at which the manifest is published.
175175
* A sequence _MAY_ have an id.
176-
* A canvas _MUST_ have an id, and it _MUST_ be an http[s] URI. The canvas's JSON representation _SHOULD_ be published at that URI.
177-
* A content resource _MUST_ have an id unless it is embedded in the response, and it _MUST_ be the http[s] URI at which the resource is published.
176+
* A canvas _MUST_ have an id, and it _MUST_ be an http(s) URI. The canvas's JSON representation _SHOULD_ be published at that URI.
177+
* A content resource _MUST_ have an id unless it is embedded in the response, and it _MUST_ be the http(s) URI at which the resource is published.
178178

179179
@type
180180
: The type of the resource. For the resource types defined by this specification, the value of `@type` will be described in the sections below. For content resources, the type may be drawn from other vocabularies. Recommendations for basic types such as image, text or audio are also given in the sections below.
@@ -362,7 +362,7 @@ Typically the first request will be for a manifest resource and, for optimizatio
362362

363363
#### 5.3.1. URI Representation
364364

365-
Resource descriptions _SHOULD_ be embedded within higher-level descriptions, and _MAY_ also be available via separate requests from http[s] URIs linked in the responses. These URIs are in the `@id` property for the resource. Links to resources _MAY_ be either given as just the URI if there is no additional information associated with them, or as a JSON object with the `@id` property. Other URI schemes _MAY_ be used if the resource is not able to be retrieved via HTTP. The following two lines are equivalent, however the second object form should not be used unless there is additional information associated with the resource:
365+
Resource descriptions _SHOULD_ be embedded within higher-level descriptions, and _MAY_ also be available via separate requests from http(s) URIs linked in the responses. These URIs are in the `@id` property for the resource. Links to resources _MAY_ be either given as just the URI if there is no additional information associated with them, or as a JSON object with the `@id` property. Other URI schemes _MAY_ be used if the resource is not able to be retrieved via HTTP. The following two lines are equivalent, however the second object form should not be used unless there is additional information associated with the resource:
366366

367367
{% highlight json %}
368368
// Option A, plain string
@@ -444,7 +444,7 @@ Recommended URI pattern:
444444

445445
The manifest response contains sufficient information for the client to initialize itself and begin to display something quickly to the user. The manifest resource represents a single object and any intellectual work or works embodied within that object. In particular it includes the descriptive, rights and linking information for the object. It then embeds the sequence(s) of canvases that should be rendered to the user.
446446

447-
The identifier in `@id` _MUST_ always be able to be dereferenced to retrieve the JSON description of the manifest, and thus _MUST_ use the http[s] URI scheme. After the descriptive information, there is then a `sequences` section, which is a list of objects. Each object is a sequence, described in the next section, that represents the order of the views and the first such sequence should be included within the manifest as well as optionally being available from its own URI. Subsequent sequences _SHOULD_ only be referenced with their identifier (`@id`), class (`@type`) and `label` and thus _MUST_ be dereferenced by clients in order to process them if the user selects to view that sequence.
447+
The identifier in `@id` _MUST_ always be able to be dereferenced to retrieve the JSON description of the manifest, and thus _MUST_ use the http(s) URI scheme. After the descriptive information, there is then a `sequences` section, which is a list of objects. Each object is a sequence, described in the next section, that represents the order of the views and the first such sequence should be included within the manifest as well as optionally being available from its own URI. Subsequent sequences _SHOULD_ only be referenced with their identifier (`@id`), class (`@type`) and `label` and thus _MUST_ be dereferenced by clients in order to process them if the user selects to view that sequence.
448448

449449
The example below includes only the manifest-level information, however it _MUST_ embed the sequence, canvas and content information. It includes examples in the descriptive metadata for how to associate multiple entries with a single field and how to be explicit about the language of a particular entry.
450450

@@ -523,7 +523,7 @@ Recommended URI pattern:
523523

524524
The sequence conveys the ordering of the views of the object. The default sequence (and typically the only sequence) _MUST_ be embedded within the manifest, and _MAY_ also be available from its own URI. The default sequence _MAY_ have a URI to identify it. Any additional sequences _MUST_ be referred to from the manifest, not embedded within it, and thus these additional sequences _MUST_ have an HTTP URI.
525525

526-
The new {name} parameter in the URI structure _MUST_ distinguish it from any other sequences that may be available for the physical object. Typical default names for sequences are "normal" or "basic". Names _SHOULD_ begin with a character in the range [a-zA-Z].
526+
The new {name} parameter in the URI structure _MUST_ distinguish it from any other sequences that may be available for the physical object. Typical default names for sequences are "normal" or "basic". Names _SHOULD_ begin with an alphabetical character.
527527

528528
Sequences _MAY_ have their own descriptive, rights and linking metadata using the same fields as for manifests. The `label` property _MAY_ be given for sequences and _MUST_ be given if there is more than one referenced from a manifest. After the metadata, the set of pages in the object, represented by canvas resources, are listed in order in the `canvases` property. There _MUST_ be at least one canvas given.
529529

@@ -577,7 +577,7 @@ Recommended URI pattern:
577577
```
578578
{: .urltemplate}
579579

580-
The canvas represents an individual page or view and acts as a central point for laying out the different content resources that make up the display. Canvases _MUST_ be identified by a URI and it _MUST_ be an HTTP[s] URI. If following the recommended URI pattern, the {name} parameter _MUST_ uniquely distinguish the canvas from all other canvases in the object. As with sequences, the name _SHOULD NOT_ begin with a number. Suggested patterns are "f1r" or "p1".
580+
The canvas represents an individual page or view and acts as a central point for laying out the different content resources that make up the display. Canvases _MUST_ be identified by a URI and it _MUST_ be an HTTP(s) URI. If following the recommended URI pattern, the {name} parameter _MUST_ uniquely distinguish the canvas from all other canvases in the object. As with sequences, the name _SHOULD NOT_ begin with a number. Suggested patterns are "f1r" or "p1".
581581

582582
Every canvas _MUST_ have a `label` to display, and a `height` and a `width` as integers. A canvas is a two-dimensional rectangular space with an aspect ratio that represents a single logical view of some part of the object, and the aspect ratio is given with the height and width properties. This allows resources to be associated with specific parts of the canvas, rather than the entire space. Content _MUST NOT_ be associated with space outside of the canvas's dimensions, such as at coordinates below 0,0 or greater than the height or width.
583583

@@ -674,7 +674,7 @@ For some objects, there may be more than just images available to represent the
674674

675675
The {name} parameter in the URI pattern _MUST_ uniquely distinguish it from all other lists, and is typically the same name as the canvas. As a single canvas may have multiple lists of additional resources, perhaps divided by type, this _MUST NOT_ be assumed however, and the URIs must be followed rather than constructed _a priori_. As with other uses of the {name} parameter, it _SHOULD NOT_ begin with a number.
676676

677-
The annotation list _MUST_ have an http[s] URI given in `@id`, and the the JSON representation _MUST_ be returned when that URI is dereferenced. They _MAY_ have any of the other fields defined in this specification.
677+
The annotation list _MUST_ have an http(s) URI given in `@id`, and the the JSON representation _MUST_ be returned when that URI is dereferenced. They _MAY_ have any of the other fields defined in this specification.
678678

679679
The list of resource associations are given in a `resources` list. The items in the list are annotations, as described above, however the resource linked by the annotation is something other than an image. The canvas URI _MUST_ be repeated in the `on` field, as above.
680680

@@ -1015,7 +1015,7 @@ Recommended URI pattern:
10151015
```
10161016
{: .urltemplate}
10171017

1018-
It may be important to describe additional structure within an object, such as newspaper articles that span pages, the range of non-content-bearing pages at the beginning of a work, or chapters within a book. These are described using ranges in a similar manner to sequences. Ranges _MUST_ have URIs and they _SHOULD_ be http[s] URIs. The intent of adding a range to the manifest is to allow the client to display a structured hierarchy to enable the user to navigate within the object without merely stepping through the current sequence. The rationale for separating ranges from sequences is that there is likely to be overlap between different ranges, such as the physical structure of a book compared to the textual structure of the work. An example would be a newspaper with articles that are continued in different sections, or simply a section that starts half way through a page.
1018+
It may be important to describe additional structure within an object, such as newspaper articles that span pages, the range of non-content-bearing pages at the beginning of a work, or chapters within a book. These are described using ranges in a similar manner to sequences. Ranges _MUST_ have URIs and they _SHOULD_ be http(s) URIs. The intent of adding a range to the manifest is to allow the client to display a structured hierarchy to enable the user to navigate within the object without merely stepping through the current sequence. The rationale for separating ranges from sequences is that there is likely to be overlap between different ranges, such as the physical structure of a book compared to the textual structure of the work. An example would be a newspaper with articles that are continued in different sections, or simply a section that starts half way through a page.
10191019

10201020
A range will typically include one or more canvases or, different to sequences, parts of canvases. The part must be rectangular, and is given using the `xywh=` fragment approach. This allows for selecting, for example, the areas within two newspaper pages where an article is located. As the information about the canvas is already in the sequence, it _MUST_ not be repeated. In order to present a table of the different ranges to allow a user to select one, every range _MUST_ have a label and the top most range in the table _SHOULD_ have a `viewingHint` with the value "top". A range that is the top of a hierarchy does not need to list all of the canvases in the sequence, and _SHOULD_ only give the list of ranges below it. Ranges _MAY_ also have any of the other properties defined in this specification, including the `startCanvas` relationship to the first canvas within the range to start with, if it is not the first listed in `canvases`.
10211021

source/api/presentation/usecases.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,4 @@ Thanks to the members of the [IIIF][iiif-community] for their continuous engagem
9090
[icon-opt]: /img/metadata-api/optional.png "Optional"
9191
[icon-na]: /img/metadata-api/not_allowed.png "Not allowed"
9292

93-
{% for acronym in site.data.acronyms %}
94-
*[{{ acronym[0] }}]: {{ acronym[1] }}
95-
{% endfor %}
96-
93+
{% include acronyms.md %}

spec/source/syntax_spec.rb

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require 'spec_helper'
2+
require 'open3'
3+
4+
describe 'Editors' do
5+
6+
they 'tend to screw up markdown' do
7+
8+
report = {}
9+
template = 'cat %s | kramdown 2>&1 >/dev/null | grep "link ID \'[a-zA-Z][_0-9a-zA-Z-]*\'"'
10+
glob_pattern = File.join(File.expand_path('../../../source', __FILE__), '**/*.md')
11+
markdown_files = Dir.glob(glob_pattern)
12+
markdown_files.each do |mf|
13+
unless mf.end_with?('acronyms.md')
14+
stdin, stdout, stderr, wait_thr = Open3.popen3(template % [mf])
15+
errors = stdout.read.split('\n').map(&:strip)
16+
unless errors.length == 0
17+
report[mf] = errors
18+
end
19+
end
20+
end
21+
22+
if report != {}
23+
$stderr.puts '*'*80
24+
report.each do |k,v|
25+
$stderr.puts k
26+
$stderr.puts v
27+
end
28+
$stderr.puts '*'*80
29+
end
30+
31+
expect(report.empty?).to be_truthy
32+
33+
end
34+
end

spec/spec_helper.rb

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# This file was generated by the `rspec --init` command. Conventionally, all
2+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
4+
# file to always be loaded, without a need to explicitly require it in any files.
5+
#
6+
# Given that it is always loaded, you are encouraged to keep this file as
7+
# light-weight as possible. Requiring heavyweight dependencies from this file
8+
# will add to the boot time of your test suite on EVERY test run, even for an
9+
# individual file that may not need all of that loaded. Instead, consider making
10+
# a separate helper file that requires the additional dependencies and performs
11+
# the additional setup, and require it from the spec files that actually need it.
12+
#
13+
# The `.rspec` file also contains a few flags that are not defaults but that
14+
# users commonly want.
15+
#
16+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17+
RSpec.configure do |config|
18+
# rspec-expectations config goes here. You can use an alternate
19+
# assertion/expectation library such as wrong or the stdlib/minitest
20+
# assertions if you prefer.
21+
22+
config.alias_example_to :they
23+
24+
config.expect_with :rspec do |expectations|
25+
# This option will default to `true` in RSpec 4. It makes the `description`
26+
# and `failure_message` of custom matchers include text for helper methods
27+
# defined using `chain`, e.g.:
28+
# be_bigger_than(2).and_smaller_than(4).description
29+
# # => "be bigger than 2 and smaller than 4"
30+
# ...rather than:
31+
# # => "be bigger than 2"
32+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
33+
end
34+
35+
# rspec-mocks config goes here. You can use an alternate test double
36+
# library (such as bogus or mocha) by changing the `mock_with` option here.
37+
config.mock_with :rspec do |mocks|
38+
# Prevents you from mocking or stubbing a method that does not exist on
39+
# a real object. This is generally recommended, and will default to
40+
# `true` in RSpec 4.
41+
mocks.verify_partial_doubles = true
42+
end
43+
44+
# The settings below are suggested to provide a good initial experience
45+
# with RSpec, but feel free to customize to your heart's content.
46+
=begin
47+
# These two settings work together to allow you to limit a spec run
48+
# to individual examples or groups you care about by tagging them with
49+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
50+
# get run.
51+
config.filter_run :focus
52+
config.run_all_when_everything_filtered = true
53+
54+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
55+
# For more details, see:
56+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
57+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
58+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
59+
config.disable_monkey_patching!
60+
61+
# This setting enables warnings. It's recommended, but in some cases may
62+
# be too noisy due to issues in dependencies.
63+
config.warnings = true
64+
65+
# Many RSpec users commonly either run the entire suite or an individual
66+
# file, and it's useful to allow more verbose output when running an
67+
# individual spec file.
68+
if config.files_to_run.one?
69+
# Use the documentation formatter for detailed output,
70+
# unless a formatter has already been configured
71+
# (e.g. via a command-line flag).
72+
config.default_formatter = 'doc'
73+
end
74+
75+
# Print the 10 slowest examples and example groups at the
76+
# end of the spec run, to help surface which specs are running
77+
# particularly slow.
78+
config.profile_examples = 10
79+
80+
# Run specs in random order to surface order dependencies. If you find an
81+
# order dependency and want to debug it, you can fix the order by providing
82+
# the seed, which is printed after each run.
83+
# --seed 1234
84+
config.order = :random
85+
86+
# Seed global randomization in this process using the `--seed` CLI option.
87+
# Setting this allows you to use `--seed` to deterministically reproduce
88+
# test failures related to randomization by passing the same `--seed` value
89+
# as the one that triggered the failure.
90+
Kernel.srand config.seed
91+
=end
92+
end

test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
bundle exec jekyll build --drafts
66
grunt test
77
bundle exec htmlproof ./_site
8+
rspec

0 commit comments

Comments
 (0)