openstax_kitchen 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +37 -17
  3. data/.github/config.yml +14 -0
  4. data/.github/workflows/tests.yml +5 -15
  5. data/.gitignore +1 -1
  6. data/.inch.yml +6 -0
  7. data/.rubocop.yml +65 -0
  8. data/CHANGELOG.md +16 -0
  9. data/Gemfile +5 -3
  10. data/Gemfile.lock +54 -5
  11. data/README.md +58 -11
  12. data/Rakefile +5 -3
  13. data/bin/console +4 -3
  14. data/docker/Dockerfile +36 -0
  15. data/docker/Dockerfile.ci +10 -0
  16. data/docker/bash +5 -1
  17. data/docker/build +10 -0
  18. data/docker/ci +16 -0
  19. data/docker/run +9 -0
  20. data/docker/tag_and_push_latest +17 -0
  21. data/lefthook.yml +6 -0
  22. data/lib/kitchen/ancestor.rb +38 -1
  23. data/lib/kitchen/book_document.rb +20 -2
  24. data/lib/kitchen/book_element.rb +24 -3
  25. data/lib/kitchen/book_element_enumerator.rb +4 -0
  26. data/lib/kitchen/book_recipe.rb +15 -1
  27. data/lib/kitchen/chapter_element.rb +43 -3
  28. data/lib/kitchen/chapter_element_enumerator.rb +9 -1
  29. data/lib/kitchen/clipboard.rb +35 -4
  30. data/lib/kitchen/composite_chapter_element.rb +20 -1
  31. data/lib/kitchen/composite_page_element.rb +25 -2
  32. data/lib/kitchen/composite_page_element_enumerator.rb +8 -0
  33. data/lib/kitchen/config.rb +14 -7
  34. data/lib/kitchen/counter.rb +9 -2
  35. data/lib/kitchen/debug/print_recipe_error.rb +53 -35
  36. data/lib/kitchen/directions/.rubocop.yml +22 -0
  37. data/lib/kitchen/directions/bake_appendix.rb +4 -4
  38. data/lib/kitchen/directions/bake_chapter_glossary.rb +10 -7
  39. data/lib/kitchen/directions/bake_chapter_introductions.rb +6 -6
  40. data/lib/kitchen/directions/bake_chapter_key_equations.rb +9 -6
  41. data/lib/kitchen/directions/bake_chapter_summary.rb +16 -13
  42. data/lib/kitchen/directions/bake_chapter_title/main.rb +11 -0
  43. data/lib/kitchen/directions/bake_chapter_title/v1.rb +24 -0
  44. data/lib/kitchen/directions/bake_composite_pages.rb +2 -2
  45. data/lib/kitchen/directions/bake_example.rb +6 -4
  46. data/lib/kitchen/directions/bake_exercises/main.rb +11 -0
  47. data/lib/kitchen/directions/bake_exercises/v1.rb +166 -0
  48. data/lib/kitchen/directions/bake_figure.rb +8 -5
  49. data/lib/kitchen/directions/bake_footnotes/main.rb +2 -2
  50. data/lib/kitchen/directions/bake_footnotes/v1.rb +4 -4
  51. data/lib/kitchen/directions/bake_index/main.rb +2 -2
  52. data/lib/kitchen/directions/bake_index/v1.rb +22 -15
  53. data/lib/kitchen/directions/bake_link_placeholders.rb +24 -0
  54. data/lib/kitchen/directions/bake_math_in_paragraph.rb +5 -3
  55. data/lib/kitchen/directions/bake_notes.rb +8 -8
  56. data/lib/kitchen/directions/bake_numbered_table/main.rb +2 -2
  57. data/lib/kitchen/directions/bake_numbered_table/v1.rb +21 -16
  58. data/lib/kitchen/directions/bake_page_abstracts.rb +14 -0
  59. data/lib/kitchen/directions/bake_preface/main.rb +11 -0
  60. data/lib/kitchen/directions/bake_preface/v1.rb +18 -0
  61. data/lib/kitchen/directions/bake_stepwise.rb +7 -7
  62. data/lib/kitchen/directions/bake_suggested_reading.rb +26 -0
  63. data/lib/kitchen/directions/bake_toc.rb +41 -22
  64. data/lib/kitchen/directions/bake_unit_title/main.rb +11 -0
  65. data/lib/kitchen/directions/bake_unit_title/v1.rb +23 -0
  66. data/lib/kitchen/directions/bake_unnumbered_tables.rb +7 -5
  67. data/lib/kitchen/directions/move_title_text_into_span.rb +2 -2
  68. data/lib/kitchen/document.rb +72 -13
  69. data/lib/kitchen/element.rb +11 -0
  70. data/lib/kitchen/element_base.rb +276 -56
  71. data/lib/kitchen/element_enumerator.rb +8 -0
  72. data/lib/kitchen/element_enumerator_base.rb +210 -28
  73. data/lib/kitchen/element_enumerator_factory.rb +59 -52
  74. data/lib/kitchen/element_factory.rb +27 -12
  75. data/lib/kitchen/errors.rb +5 -0
  76. data/lib/kitchen/example_element.rb +19 -1
  77. data/lib/kitchen/example_element_enumerator.rb +9 -1
  78. data/lib/kitchen/figure_element.rb +36 -2
  79. data/lib/kitchen/figure_element_enumerator.rb +9 -1
  80. data/lib/kitchen/metadata_element.rb +28 -0
  81. data/lib/kitchen/metadata_element_enumerator.rb +21 -0
  82. data/lib/kitchen/mixins/block_error_if.rb +24 -4
  83. data/lib/kitchen/note_element.rb +37 -7
  84. data/lib/kitchen/note_element_enumerator.rb +9 -1
  85. data/lib/kitchen/oven.rb +66 -15
  86. data/lib/kitchen/page_element.rb +62 -13
  87. data/lib/kitchen/page_element_enumerator.rb +9 -1
  88. data/lib/kitchen/pantry.rb +28 -1
  89. data/lib/kitchen/patches/nokogiri.rb +19 -2
  90. data/lib/kitchen/patches/renderable.rb +9 -3
  91. data/lib/kitchen/patches/string.rb +8 -0
  92. data/lib/kitchen/recipe.rb +38 -34
  93. data/lib/kitchen/search_history.rb +43 -4
  94. data/lib/kitchen/search_query.rb +84 -0
  95. data/lib/kitchen/selectors/base.rb +26 -0
  96. data/lib/kitchen/selectors/standard_1.rb +8 -0
  97. data/lib/kitchen/table_element.rb +54 -3
  98. data/lib/kitchen/table_element_enumerator.rb +9 -1
  99. data/lib/kitchen/term_element.rb +15 -1
  100. data/lib/kitchen/term_element_enumerator.rb +9 -1
  101. data/lib/kitchen/transliterations.rb +7 -5
  102. data/lib/kitchen/type_casting_element_enumerator.rb +17 -1
  103. data/lib/kitchen/unit_element.rb +39 -0
  104. data/lib/kitchen/unit_element_enumerator.rb +20 -0
  105. data/lib/kitchen/utils.rb +10 -13
  106. data/lib/kitchen/version.rb +5 -1
  107. data/lib/locales/en.yml +6 -0
  108. data/lib/openstax_kitchen.rb +43 -42
  109. data/openstax_kitchen.gemspec +26 -20
  110. data/tutorials/00/solution1.rb +9 -0
  111. data/tutorials/00/solution2.rb +8 -0
  112. data/tutorials/01/solution1.rb +18 -0
  113. data/tutorials/01/solution2.rb +26 -0
  114. data/tutorials/02/solution1.rb +31 -0
  115. data/tutorials/03/{solution_1.rb → solution1.rb} +6 -4
  116. data/tutorials/03/solution2.rb +18 -0
  117. data/tutorials/04/{solution_1.rb → solution1.rb} +4 -2
  118. data/tutorials/04/{solution_2.rb → solution2.rb} +6 -4
  119. data/tutorials/05/solution1.rb +11 -0
  120. data/tutorials/check_it +16 -15
  121. data/tutorials/setup_my_recipes +7 -6
  122. metadata +101 -22
  123. data/Dockerfile +0 -19
  124. data/docker-compose.yml +0 -12
  125. data/docker/entrypoint +0 -9
  126. data/lib/kitchen/directions/bake_exercises.rb +0 -164
  127. data/tutorials/00/solution_1.rb +0 -7
  128. data/tutorials/00/solution_2.rb +0 -6
  129. data/tutorials/01/solution_1.rb +0 -16
  130. data/tutorials/01/solution_2.rb +0 -24
  131. data/tutorials/02/solution_1.rb +0 -29
  132. data/tutorials/03/solution_2.rb +0 -15
  133. data/tutorials/05/solution_1.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47c8699f2836cea06df2e5a97aa79c350662e8193c9c1abfafd50740de61cbf6
4
- data.tar.gz: 2384b847a91f55624ca266274fb273f98cfcaeb81962c988b04efcb0d619f2a1
3
+ metadata.gz: f404296c40eba5dbfdeeb4c4de0d11492eb327e94d49c96689b262a03bc838de
4
+ data.tar.gz: b97faf532e7e098dba23ef1d1f3c42ca7c051d7fc6ad8351fa6b20209cb99ddd
5
5
  SHA512:
6
- metadata.gz: 6a617ef7617b5ebb0ae959615125a82945f965fcb7cbc080eff8da974fb843bd81fc72226fc62d9439f9012d95af21c80e6d85d81a1a0594c7b7546d8fd6e6f8
7
- data.tar.gz: cad462c3c8809912d290148a5c5f64fd8518bd8043ba66d315babeed504dc083761014abd038a9fea8eb88caaa9dcc930be4f9c0b4f048e3590a0645b8bf0da9
6
+ metadata.gz: 7f8e774352355cc44b01765b101e97db3128e19e7416a6d5138d0a83db4378e7910d196e42849237e2130c6f7463db6f13679d53ac666b6a0abf6f867ecf6a36
7
+ data.tar.gz: 84fece5f5d36f16324022d3ca34b6827f6549bed21551caedbb2845ff41d5b7b1f4b47c8e07a6fac6b14ed2e5f092435b63618a3b9e0f925a40cda21b04babfb
@@ -1,19 +1,39 @@
1
1
  {
2
- "name": "Kitchen Dev",
3
- "dockerComposeFile": ["../docker-compose.yml"],
4
- "service": "app",
5
- "workspaceFolder": "/code",
6
- "shutdownAction": "stopCompose",
7
- "extensions": [
8
- "castwide.solargraph",
9
- ],
10
- "settings": {
11
- "[ruby]": {
12
- "editor.insertSpaces": true,
13
- "editor.tabSize": 2
14
- },
15
- "solargraph.commandPath": "/usr/local/bundle/bin/solargraph",
16
- "solargraph.bundlerPath": "/usr/local/bin/bundle",
17
- },
18
- "postCreateCommand": "bundle install"
2
+ "name": "Kitchen Dev",
3
+ "build": {
4
+ "dockerfile": "../docker/Dockerfile",
5
+ "context": "..",
6
+ "args": {
7
+ "bundler_version": "2.2.4"
8
+ }
9
+ },
10
+ "workspaceMount": "source=${localWorkspaceFolder},target=/code,type=bind,consistency=default",
11
+ "workspaceFolder": "/code",
12
+ "extensions": [
13
+ "castwide.solargraph",
14
+ "rebornix.Ruby",
15
+ "MS-vsliveshare.vsliveshare-pack"
16
+ ],
17
+ "settings": {
18
+ "files.trimTrailingWhitespace": true,
19
+ "files.insertFinalNewline": true,
20
+ "terminal.integrated.shell.linux": "/bin/bash",
21
+ "[ruby]": {
22
+ "editor.insertSpaces": true,
23
+ "editor.tabSize": 2,
24
+ },
25
+ "ruby.lint": {
26
+ "rubocop": {
27
+ "useBundler": true // enable rubocop via bundler
28
+ },
29
+ },
30
+ "ruby.format": "rubocop", // use rubocop for formatting
31
+ "ruby.useLanguageServer": true,
32
+ "solargraph.commandPath": "/usr/local/bundle/bin/solargraph",
33
+ "solargraph.bundlerPath": "/usr/local/bin/bundle",
34
+ "ruby.rubocop.executePath": "/usr/local/bundle/bin/",
35
+ "ruby.rubocop.onSave": true,
36
+ "ruby.rubocop.configFilePath": "/code/.rubocop.yml",
37
+ "terminal.integrated.scrollback": 100000
38
+ }
19
39
  }
@@ -0,0 +1,14 @@
1
+ # See https://github.com/openstax/staxly#plugins for more options for this file
2
+ changelog:
3
+ # See https://github.com/mikz/probot-changelog for details
4
+
5
+ # The filename of the CHANGELOG that needs to be updated in every PullRequest
6
+ filename: CHANGELOG.md
7
+
8
+ # (optional) when files matching these patterns are changed then disallow merging
9
+ # until the CHANGELOG is updated.
10
+ # If this pattern is not included then **all** Pull Requests require an edit to
11
+ # the CHANGELOG file
12
+
13
+ # include:
14
+ # - /^src\//
@@ -5,32 +5,22 @@ on:
5
5
  push:
6
6
  branches:
7
7
  - main
8
- schedule:
9
- - cron: '0 0 * * 0' # weekly
10
8
 
11
9
  jobs:
12
- tests:
10
+ rspec:
13
11
  timeout-minutes: 10
14
12
  runs-on: ubuntu-18.04
15
13
 
16
14
  steps:
17
15
  - uses: actions/checkout@v2
18
- - uses: actions/setup-ruby@v1
19
- with:
20
- ruby-version: 2.6
21
16
  - uses: actions/cache@v2
22
17
  with:
23
18
  path: vendor/bundle
24
19
  key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
25
20
  restore-keys: |
26
21
  ${{ runner.os }}-gems-
27
- - name: Test
28
- env:
29
- ENABLE_CODECOV: 1
22
+ - name: Build docker image and run specs within it
23
+ # See https://docs.codecov.io/docs/testing-with-docker
30
24
  run: |
31
- gem install bundler --force --no-document --version 2.1.4
32
- bundle config deployment true
33
- bundle config path vendor/bundle
34
- bundle config jobs 2
35
- bundle install
36
- bundle exec rake
25
+ ./docker/build --ci
26
+ CI_ENV=`bash <(curl -s https://codecov.io/env)` ./docker/ci
data/.gitignore CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
- .irb_history
13
+ .irb-history
14
14
  .byebug_history
15
15
  bin/scratch
16
16
  tutorial/outputs/*.html
data/.inch.yml ADDED
@@ -0,0 +1,6 @@
1
+ files:
2
+ # define files excluded from the analysis (defaults to [])
3
+ excluded:
4
+ - lib/kitchen/directions/**/*.rb # may want to add this in later in a limited way
5
+ - lib/kitchen/debug/**/*.rb
6
+ - lib/openstax_kitchen.rb
data/.rubocop.yml ADDED
@@ -0,0 +1,65 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Layout/EmptyLinesAroundClassBody:
5
+ Enabled: false
6
+
7
+ Layout/EmptyLinesAroundBlockBody:
8
+ Enabled: false
9
+
10
+ Layout/LineLength:
11
+ Max: 100
12
+ IgnoredPatterns: ['(\A|\s)#']
13
+
14
+ Metrics/AbcSize:
15
+ Max: 50
16
+
17
+ Naming/PredicateName:
18
+ Enabled: false
19
+
20
+ Metrics/ClassLength:
21
+ Max: 300
22
+ CountAsOne: ['heredoc']
23
+
24
+ Metrics/MethodLength:
25
+ Max: 50
26
+ CountAsOne: ['heredoc']
27
+
28
+ Metrics/BlockLength:
29
+ CountAsOne: ['heredoc']
30
+ Max: 30
31
+ Exclude:
32
+ - 'openstax_kitchen.gemspec'
33
+
34
+ Metrics/ModuleLength:
35
+ CountAsOne: ['heredoc']
36
+
37
+ Style/Alias:
38
+ EnforcedStyle: prefer_alias_method
39
+
40
+ Style/StringLiterals:
41
+ ConsistentQuotesInMultiline: true
42
+
43
+ Layout/SpaceAroundEqualsInParameterDefault:
44
+ EnforcedStyle: no_space
45
+
46
+ Style/AccessorGrouping:
47
+ EnforcedStyle: separated
48
+
49
+ Style/SingleLineMethods:
50
+ Enabled: false # don't abuse it, but sometimes it is right
51
+
52
+ Style/RegexpLiteral:
53
+ AllowInnerSlashes: true
54
+
55
+ Style/SymbolProc:
56
+ IgnoredMethods:
57
+ - respond_to
58
+ - define_method
59
+ - XML # For Nokogiri::XML
60
+
61
+ Layout/ClosingParenthesisIndentation:
62
+ Enabled: false # when true hanging parens look weird
63
+
64
+ Layout/MultilineMethodCallBraceLayout:
65
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -6,8 +6,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.0.0] - 2021-03-17
10
+
11
+ * Added a subfigure? method to `FigureElements`(minor)
12
+ * Added support for titles in `BakeFigure` (minor)
13
+ * Created `BakeUnitTitle` class
14
+ * Created `UnitElement` and `UnitElementEnumerator` classes (minor)
15
+ * Added support for Units in `BakeToc` direction (minor)
16
+ * Added `Unit` to `en.yml` (patch)
17
+ * Remove chapter summary titles only if they exist (minor)
18
+ * Created `BakeSuggestedReading` direction for EOC
19
+ * Added ability to filter searches based on `only` and `except` conditions, which can be names of element methods or blocks of code (minor)
20
+ * Changed from tracking and using `css_or_xpath` strings and arrays to `search_query` objects that
21
+ wrap `css_or_xpath` variables along with `only` and `except` conditions. (major?)
22
+
9
23
  ## [2.0.0] - 2020-12-18
10
24
 
25
+ * Refactored bake_exercises to better support parallel work on multiple versions.
26
+ (minor change) Does not affect existing recipes.
11
27
  * Changed the main gem source file to have the same name as the gem (`openstax_kitchen`) so that you don't have to `require` a different name than you use in your `gem` call.
12
28
 
13
29
  ## [1.0.0] - 2020-12-15
data/Gemfile CHANGED
@@ -1,9 +1,11 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in kitchen.gemspec
4
6
  gemspec
5
7
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
8
10
 
9
11
  gem 'codecov', require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (2.0.0)
4
+ openstax_kitchen (3.0.0)
5
5
  activesupport
6
6
  i18n
7
7
  nokogiri
@@ -16,23 +16,43 @@ GEM
16
16
  minitest (~> 5.1)
17
17
  tzinfo (~> 1.1)
18
18
  zeitwerk (~> 2.2, >= 2.2.2)
19
+ ast (2.4.1)
19
20
  byebug (11.1.2)
20
21
  codecov (0.2.13)
21
22
  simplecov (~> 0.18.0)
23
+ coderay (1.1.3)
22
24
  concurrent-ruby (1.1.7)
23
25
  diff-lcs (1.3)
24
26
  docile (1.3.3)
25
27
  i18n (1.8.5)
26
28
  concurrent-ruby (~> 1.0)
27
- mini_portile2 (2.4.0)
29
+ inch (0.8.0)
30
+ pry
31
+ sparkr (>= 0.2.0)
32
+ term-ansicolor
33
+ yard (~> 0.9.12)
34
+ method_source (1.0.0)
35
+ mini_portile2 (2.5.0)
28
36
  minitest (5.14.2)
29
- nokogiri (1.10.9)
30
- mini_portile2 (~> 2.4.0)
37
+ nokogiri (1.11.1)
38
+ mini_portile2 (~> 2.5.0)
39
+ racc (~> 1.4)
40
+ nokogiri (1.11.1-x86_64-linux)
41
+ racc (~> 1.4)
31
42
  nokogiri-diff (0.2.0)
32
43
  nokogiri (~> 1.5)
33
44
  tdiff (~> 0.3, >= 0.3.2)
45
+ parallel (1.20.1)
46
+ parser (2.7.2.0)
47
+ ast (~> 2.4.1)
48
+ pry (0.13.1)
49
+ coderay (~> 1.1)
50
+ method_source (~> 1.0)
51
+ racc (1.5.2)
34
52
  rainbow (3.0.0)
35
53
  rake (12.3.3)
54
+ regexp_parser (2.0.1)
55
+ rexml (3.2.4)
36
56
  rspec (3.9.0)
37
57
  rspec-core (~> 3.9.0)
38
58
  rspec-expectations (~> 3.9.0)
@@ -46,29 +66,58 @@ GEM
46
66
  diff-lcs (>= 1.2.0, < 2.0)
47
67
  rspec-support (~> 3.9.0)
48
68
  rspec-support (3.9.2)
69
+ rubocop (1.6.1)
70
+ parallel (~> 1.10)
71
+ parser (>= 2.7.1.5)
72
+ rainbow (>= 2.2.2, < 4.0)
73
+ regexp_parser (>= 1.8, < 3.0)
74
+ rexml
75
+ rubocop-ast (>= 1.2.0, < 2.0)
76
+ ruby-progressbar (~> 1.7)
77
+ unicode-display_width (>= 1.4.0, < 2.0)
78
+ rubocop-ast (1.3.0)
79
+ parser (>= 2.7.1.5)
80
+ rubocop-rake (0.5.1)
81
+ rubocop
82
+ rubocop-rspec (2.1.0)
83
+ rubocop (~> 1.0)
84
+ rubocop-ast (>= 1.1.0)
85
+ ruby-progressbar (1.10.1)
49
86
  simplecov (0.18.5)
50
87
  docile (~> 1.1)
51
88
  simplecov-html (~> 0.11)
52
89
  simplecov-html (0.12.3)
90
+ sparkr (0.4.1)
91
+ sync (0.5.0)
53
92
  tdiff (0.3.4)
93
+ term-ansicolor (1.7.1)
94
+ tins (~> 1.0)
54
95
  thread_safe (0.3.6)
96
+ tins (1.26.0)
97
+ sync
55
98
  tzinfo (1.2.7)
56
99
  thread_safe (~> 0.1)
100
+ unicode-display_width (1.7.0)
57
101
  yard (0.9.24)
58
102
  zeitwerk (2.4.0)
59
103
 
60
104
  PLATFORMS
61
105
  ruby
106
+ x86_64-linux
62
107
 
63
108
  DEPENDENCIES
64
109
  byebug
65
110
  codecov
111
+ inch
66
112
  nokogiri-diff
67
113
  openstax_kitchen!
68
114
  rainbow
69
115
  rake (~> 12.0)
70
116
  rspec (~> 3.0)
117
+ rubocop
118
+ rubocop-rake
119
+ rubocop-rspec
71
120
  yard
72
121
 
73
122
  BUNDLED WITH
74
- 2.1.4
123
+ 2.2.4
data/README.md CHANGED
@@ -3,7 +3,9 @@
3
3
  [![Tests](https://github.com/openstax/kitchen/workflows/Tests/badge.svg)](https://github.com/openstax/kitchen/actions?query=workflow:Tests)
4
4
  [![Coverage Status](https://img.shields.io/codecov/c/github/openstax/kitchen.svg)](https://codecov.io/gh/openstax/kitchen)
5
5
 
6
- Kitchen lets you modify the structure and content of XML files. You create a `Recipe` with instructions and `bake` it in the `Oven`
6
+ Kitchen lets you modify the structure and content of XML files. You create a `Recipe` with instructions and `bake` it in the `Oven`.
7
+
8
+ [Full documentation at rubydoc.info](https://rubydoc.info/github/openstax/kitchen).
7
9
 
8
10
  ## Installation
9
11
 
@@ -19,7 +21,7 @@ And then execute:
19
21
 
20
22
  Or install it yourself as:
21
23
 
22
- $ gem install kitchen
24
+ $ gem install openstax_kitchen
23
25
 
24
26
  ## Two Ways to Use Kitchen
25
27
 
@@ -271,6 +273,31 @@ The CSS for these specific search methods is hidden away so you don't have to de
271
273
  doc.book.tables("$.unnumbered").cut
272
274
  ```
273
275
 
276
+ Sometimes, it is difficult to setup a search using CSS. In such cases, you can also pass `only` and `except` arguments to search methods, e.g.:
277
+
278
+ ```ruby
279
+ doc.book.figures(except: :subfigure?)
280
+ ```
281
+
282
+ `only` and `except` can be the names of methods (that return truthy/falsy values) on the element being iterated over, as shown above, or they can be lambdas or procs as shown here:
283
+
284
+ ```ruby
285
+ doc.book.figures(only: ->(fig) { fig.children.count == 2 })
286
+ ```
287
+
288
+ Obviously this is a somewhat contrived example, but the idea is that by passing a callable you can do complex searches.
289
+
290
+ ### Overriding Default Book-Oriented Selectors
291
+
292
+ Book-oriented methods like `book.pages.figures` hide from us the CSS or XPath selectors that let us find child elements like `.pages`. But sometimes, the default selector we have isn't what is used in a certain book. In these cases, we can override the selector once in the recipe and still continue to use the book-oriented usage. For example, a page summary is normally found using the CSS `section.summary`. But some books use a `.section-summary` class. For these books, we can override the selectors in their recipes:
293
+
294
+ ```ruby
295
+ recipe = Kitchen::BookRecipe.new do |doc|
296
+ doc.selectors.override(
297
+ page_summary: ".section-summary"
298
+ )
299
+ ```
300
+
274
301
  ## Directions
275
302
 
276
303
  All of the above talks about the how to search through the XML file and perform basic operations on that file. Our recipes will be combinations of all of the above: search for elements; cut, copy and paste them; count them; rework them; etc.
@@ -452,19 +479,23 @@ Incidentally, the `bake` method returns timing information, if you `puts` its re
452
479
 
453
480
  ### Docker
454
481
 
455
- You can use Docker for your development environment.
482
+ You can use Docker for your development environment. To build the image:
456
483
 
457
484
  ```bash
458
- $> docker-compose up -d
485
+ $> ./docker/build
459
486
  ```
460
487
 
461
- to build and run the Docker container, then:
488
+ To drop into the running container:
462
489
 
463
490
  ```bash
464
491
  $> ./docker/bash
465
492
  ```
466
493
 
467
- To drop into the container at the command line.
494
+ To run specs (or something else) from the host:
495
+
496
+ ```bash
497
+ $> ./docker/run rspec
498
+ ```
468
499
 
469
500
  ### Non-Docker
470
501
 
@@ -583,6 +614,8 @@ Run `yard server --reload` to watch for changes in your local codebase everytime
583
614
 
584
615
  Navidate to `http://localhost:8808/` to view documentation in your browser.
585
616
 
617
+ Use the `inch` gem to get feedback on where documentation is lacking `bundle exec inch` (add `--help` for more options).
618
+
586
619
  ### Specs
587
620
 
588
621
  Run `bundle exec rspec` to run the specs. `rake rspec` probably does the same thing.
@@ -609,7 +642,25 @@ expect(book_1).to match_html_nodes("some string of HTML here")
609
642
  4. Click "Remote-Containers: Open Folder in Container"
610
643
  5. Select the cloned kitchen folder.
611
644
 
612
- This (assuming you have Docker installed) will launch a docker container for Kitchen, install Ruby and needed libraries, and then let you edit the code running in that container through VSCode. Solargraph will work (code completion and inline documentation).
645
+ This (assuming you have Docker installed) will launch a docker container for Kitchen, install Ruby and needed libraries, and then let you edit the code running in that container through VSCode. Solargraph will work (code completion and inline documentation) as will Rubocop for linting.
646
+
647
+ ### Rubocop
648
+
649
+ Rubocop is good for helping us keep our code style standardized, but it isn't the end-all be-all of things. We can disable certain checks within a file, e.g.
650
+
651
+ ```ruby
652
+ # rubocop:disable Style/NumericPredicate
653
+ ```
654
+
655
+ or we can disable or change global settings in the `.rubocop.yml` file.
656
+
657
+ Rubocop is setup to run within the VSCode dev container (see above).
658
+
659
+ The [lefthook](https://github.com/Arkweid/lefthook) is included in the Docker build. When you push your code to GitHub, lefthook runs Rubocop on all the files you have changed. It won't let you push if you have Rubocop errors. You'll have to fix the errors or make changes to the `.rubocop.yml` files to bypass the errors. You can also run lefthook directly with
660
+
661
+ ```bash
662
+ $ /code> lefthook run pre-push
663
+ ```
613
664
 
614
665
  #### Misc References
615
666
 
@@ -643,13 +694,9 @@ The gem is available as open source under the terms of the [MIT License](https:/
643
694
  ## TODO
644
695
 
645
696
  * Specs galore :-)
646
- * `$` search path substitution (making sure not to mess up xpath)
647
697
  * Think up and handle a bunch more recipe errors, test they all raise some kind of `RecipeError`.
648
698
  * Encapsulate numbering schemes (e.g. chapter pages are "5.2", appendix pages are "D7") and maybe set on book document? Right now we are doing inline things like `*('A'..'Z')][page.count_in(:book)-1]}#{table.count_in(:page)` which is ugly.
649
- * Add rubocop for linting.
650
699
  * Control I18n language in Oven.
651
- * Get doc normalization scripts into this repo from testkitchen (for comparing two large baked outputs).
652
- * Change from ElementBase <- Element to Element <- BasicElement
653
700
  * README: element_children, .only, selectors, config files
654
701
  * Use ERB for more readable string building?
655
702