rundoc 0.0.2 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/check_changelog.yml +13 -0
- data/.gitignore +7 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +26 -0
- data/Dockerfile +24 -0
- data/Gemfile +1 -0
- data/README.md +261 -92
- data/bin/rundoc +4 -60
- data/lib/rundoc.rb +15 -1
- data/lib/rundoc/cli.rb +84 -0
- data/lib/rundoc/code_command.rb +20 -5
- data/lib/rundoc/code_command/background.rb +9 -0
- data/lib/rundoc/code_command/background/log/clear.rb +17 -0
- data/lib/rundoc/code_command/background/log/read.rb +16 -0
- data/lib/rundoc/code_command/background/process_spawn.rb +96 -0
- data/lib/rundoc/code_command/background/start.rb +38 -0
- data/lib/rundoc/code_command/background/stop.rb +17 -0
- data/lib/rundoc/code_command/background/wait.rb +19 -0
- data/lib/rundoc/code_command/bash.rb +1 -1
- data/lib/rundoc/code_command/bash/cd.rb +21 -3
- data/lib/rundoc/code_command/file_command/append.rb +2 -0
- data/lib/rundoc/code_command/no_such_command.rb +4 -0
- data/lib/rundoc/code_command/pipe.rb +17 -4
- data/lib/rundoc/code_command/raw.rb +18 -0
- data/lib/rundoc/code_command/rundoc/depend_on.rb +37 -0
- data/lib/rundoc/code_command/rundoc/require.rb +41 -0
- data/lib/rundoc/code_command/rundoc_command.rb +6 -2
- data/lib/rundoc/code_command/website.rb +7 -0
- data/lib/rundoc/code_command/website/driver.rb +111 -0
- data/lib/rundoc/code_command/website/navigate.rb +29 -0
- data/lib/rundoc/code_command/website/screenshot.rb +28 -0
- data/lib/rundoc/code_command/website/visit.rb +47 -0
- data/lib/rundoc/code_section.rb +34 -78
- data/lib/rundoc/parser.rb +4 -3
- data/lib/rundoc/peg_parser.rb +282 -0
- data/lib/rundoc/version.rb +1 -1
- data/rundoc.gemspec +9 -3
- data/test/fixtures/build_logs/rundoc.md +56 -0
- data/test/fixtures/depend_on/dependency/rundoc.md +5 -0
- data/test/fixtures/depend_on/main/rundoc.md +10 -0
- data/test/fixtures/java/rundoc.md +9 -0
- data/test/fixtures/rails_4/rundoc.md +1 -1
- data/test/fixtures/rails_5/rundoc.md +76 -74
- data/test/fixtures/{rails_5_beta → rails_6}/rundoc.md +93 -87
- data/test/fixtures/require/dependency/rundoc.md +5 -0
- data/test/fixtures/require/main/rundoc.md +10 -0
- data/test/fixtures/screenshot/rundoc.md +10 -0
- data/test/rundoc/code_commands/append_file_test.rb +2 -2
- data/test/rundoc/code_commands/background_test.rb +69 -0
- data/test/rundoc/code_commands/bash_test.rb +1 -1
- data/test/rundoc/code_commands/pipe_test.rb +12 -2
- data/test/rundoc/code_commands/remove_contents_test.rb +1 -1
- data/test/rundoc/code_section_test.rb +6 -5
- data/test/rundoc/parser_test.rb +2 -8
- data/test/rundoc/peg_parser_test.rb +391 -0
- data/test/rundoc/regex_test.rb +1 -1
- data/test/rundoc/test_parse_java.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +120 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 64447cf981514498089c30f81d5a9885059db08ac2120b8bb700eed4089d0105
|
4
|
+
data.tar.gz: b46c802f280388c043adddcdfbe0a385fcf2bee8aa4c1fd76563452c7d24698c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf89810f545312fd23e6759015473f5d64e9991f7348344649a4b672a3e97e774702ec04d5d3b91f64b8ebb14caecf78ac0f2d583d423b1c3f25c1915eaa1e5a
|
7
|
+
data.tar.gz: 9b7f288a0b23806729f07690faf8ec1b295c45652e7db07253aba38019c50d0e30a1cfb4b9973cc97ef36ac78bb8a1139228ed9b9fc5cbf15658770817a13e5e
|
@@ -0,0 +1,13 @@
|
|
1
|
+
name: Check Changelog
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
types: [opened, reopened, edited, synchronize]
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v1
|
11
|
+
- name: Check that CHANGELOG is touched
|
12
|
+
run: |
|
13
|
+
cat $GITHUB_EVENT_PATH | jq .pull_request.title | grep -i '\[\(\(changelog skip\)\|\(ci skip\)\)\]' || git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## HEAD
|
2
|
+
|
3
|
+
## 1.1.2
|
4
|
+
|
5
|
+
- Fix pipe support (https://github.com/schneems/rundoc/pull/28)
|
6
|
+
|
7
|
+
## 1.1.1
|
8
|
+
|
9
|
+
- Fix log read race condition (https://github.com/schneems/rundoc/pull/25)
|
10
|
+
|
11
|
+
## 1.1.0
|
12
|
+
|
13
|
+
- Pipe logic is now implemented through a parser (https://github.com/schneems/rundoc/pull/22)
|
14
|
+
- Bugfix, background processes error when the log file is not touched before read, not sure why this is possible but here's a fix for it anyway (https://github.com/schneems/rundoc/commit/620ae55d8a5d3d443cf5e8cb77950a841f92900c)
|
15
|
+
|
16
|
+
## 1.0.1
|
17
|
+
|
18
|
+
- Allow non-headless browser sessions and navigation [#23](https://github.com/schneems/rundoc/pull/23)
|
19
|
+
- Fix issue where a background task's log file was not present before it was attempted to be opened.
|
20
|
+
- Allow composability of documents `rundoc.depend_on` and `rundoc.require` [#19](https://github.com/schneems/rundoc/pull/19)
|
21
|
+
- The `rundoc` command is now `rundoc.configure`.
|
22
|
+
- Ignore chdir warning since that affect is intentional [#20](https://github.com/schneems/rundoc/pull/20)
|
23
|
+
|
24
|
+
## 1.0.0
|
25
|
+
|
26
|
+
- Now using a propper PEG parser (parslet)
|
data/Dockerfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
FROM ruby:2.6.3-stretch
|
2
|
+
|
3
|
+
RUN useradd rundoc
|
4
|
+
RUN curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
|
5
|
+
|
6
|
+
RUN apt-get clean && apt-get update && apt-get install -y locales nodejs
|
7
|
+
|
8
|
+
RUN locale-gen en_US.UTF-8
|
9
|
+
ENV LC_ALL=C.UTF-8
|
10
|
+
ENV LANG=en_US.UTF-8
|
11
|
+
ENV LANGUAGE=en_US.UTF-8
|
12
|
+
ENV DISABLE_SPRING=1
|
13
|
+
|
14
|
+
WORKDIR /home/rundoc
|
15
|
+
RUN mkdir -p /home/rundoc/ && chown -R rundoc:rundoc /home/rundoc
|
16
|
+
USER rundoc
|
17
|
+
RUN mkdir -p /home/rundoc/workdir
|
18
|
+
|
19
|
+
RUN git config --global user.email "developer@example.com"
|
20
|
+
RUN git config --global user.name "Dev Eloper"
|
21
|
+
|
22
|
+
ADD Gemfile Gemfile.lock
|
23
|
+
|
24
|
+
RUN bundle install
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,37 +1,32 @@
|
|
1
1
|
# RunDOC
|
2
2
|
|
3
|
-
![](https://www.dropbox.com/s/u354td51brynr4h/Screenshot%202017-05-09%2009.36.33.png?
|
3
|
+
![](https://www.dropbox.com/s/u354td51brynr4h/Screenshot%202017-05-09%2009.36.33.png?raw=1)
|
4
4
|
|
5
5
|
## What
|
6
6
|
|
7
|
-
This library allows you to "run" your docs and embed the code as well as results back into the documentation.
|
7
|
+
This library allows you to "run" your docs and embed the code as well as results back into the documentation. Here's a quick example:
|
8
8
|
|
9
|
-
Write
|
9
|
+
Write documentation:
|
10
10
|
|
11
|
-
|
11
|
+
Install by running:
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
## Why
|
18
|
-
|
19
|
-
I wrote a [Rails course for the University of Texas](http://schneems.com), that required I build an app and write
|
20
|
-
documentation at the same time. I enjoyed the experience but having to do both essentially doubled my work load, worse than the time wasted copying snippets between the two was my docs were prone to paste errors, keyboard slips, or me just forgetting to add sections that I had implemented in the app. The only way for me to find these errors was to give the docs to someone to actually follow them and build the project. This method of manually checking is extremely time consuming, prone to errors (the developer may work around problems instead of reporting them to you), and makes making minor edits a major pain. Instead of writing your docs once and iterating, I found adding sections required me to start from scratch.
|
21
|
-
|
22
|
-
|
23
|
-
While I was writing the course I dreamed of a system where the docs and the
|
24
|
-
code could automatically stay in sync. One where if I had a typo in my tutorials, an automatic tech-editor would know and tell me. One where I couldn't accidentally skip over critical sections leaving true novices confused.
|
13
|
+
```
|
14
|
+
:::>> $ gem install rails --no-document
|
15
|
+
```
|
25
16
|
|
26
|
-
|
17
|
+
Now if you "run" this document you'll get this output:
|
27
18
|
|
28
|
-
|
19
|
+
Install by running:
|
29
20
|
|
30
|
-
|
21
|
+
```
|
22
|
+
$ gem install rails --no-document
|
23
|
+
Successfully installed rails-5.2.2
|
24
|
+
1 gem installed
|
25
|
+
```
|
31
26
|
|
32
|
-
|
27
|
+
The idea is that as your documentation "runs" it builds a working tutorial. It also acts as tests since if your docs become incorrect due to a typo or bit-rot then when you try to generate them, the process will fail.
|
33
28
|
|
34
|
-
|
29
|
+
Think of RunDOC as your ever-vigilant tech editor and writing partner.
|
35
30
|
|
36
31
|
## Install
|
37
32
|
|
@@ -44,7 +39,7 @@ $ gem install rundoc
|
|
44
39
|
or add it to your Gemfile:
|
45
40
|
|
46
41
|
```
|
47
|
-
gem 'rundoc
|
42
|
+
gem 'rundoc'
|
48
43
|
```
|
49
44
|
|
50
45
|
## Use It
|
@@ -52,24 +47,57 @@ gem 'rundoc`
|
|
52
47
|
Run the `rundoc build` command on any markdown file
|
53
48
|
|
54
49
|
```sh
|
55
|
-
$ rundoc build --path
|
50
|
+
$ rundoc build --path my/path/to/run_doc.md
|
56
51
|
```
|
57
52
|
|
58
|
-
Note: This command will create and manipulate directories in the working directory of your source markdown file. Best practice is to have your source markdown file in
|
53
|
+
> Note: This command will create and manipulate directories in the working directory of your source markdown file. Best practice is to have your source markdown file in its own empty directory.
|
59
54
|
|
60
55
|
This will generate a project folder with your project in it, and a markdown README.md with the parsed output of the markdown docs, and a copy of the source.
|
61
56
|
|
62
|
-
##
|
63
|
-
|
64
|
-
|
65
|
-
|
57
|
+
## Quick docs
|
58
|
+
|
59
|
+
- [Understanding the Syntax](#rundoc-syntax)
|
60
|
+
- [Dotenv support](#dotenv-support)
|
61
|
+
- [Rendering cheat sheet](#rendering-cheat-sheet)
|
62
|
+
|
63
|
+
### Commands
|
64
|
+
|
65
|
+
- Execute Bash Commands
|
66
|
+
- [$](#shell-commands)
|
67
|
+
- [fail.$](#shell-commands)
|
68
|
+
- Chain commands
|
69
|
+
- [pipe](#pipe)
|
70
|
+
- [|](#pipe)
|
71
|
+
- Manipulate Files
|
72
|
+
- [file.write](#file-commands)
|
73
|
+
- [file.append](#file-commands)
|
74
|
+
- [file.remove](#file-commands)
|
75
|
+
- Boot background processes such as a local server
|
76
|
+
- [background.start](#background)
|
77
|
+
- [background.stop](#background)
|
78
|
+
- [background.log.read](#background)
|
79
|
+
- [background.log.clear](#background)
|
80
|
+
- Take screenshots
|
81
|
+
- [website.visit](#screenshots)
|
82
|
+
- [website.nav](#screenshots)
|
83
|
+
- [website.screenshot](#screenshots)
|
84
|
+
- Configure RunDOC
|
85
|
+
- [rundoc.configure](#configure)
|
86
|
+
- Import and compose documents
|
87
|
+
- [rundoc.depend_on](#compose-multiple-rundoc-documents)
|
88
|
+
- [rundoc.require](#compose-multiple-rundoc-documents)
|
89
|
+
|
90
|
+
## RunDOC Syntax
|
91
|
+
|
92
|
+
RunDOC uses GitHub flavored markdown. This means you write like normal but in your code sections
|
93
|
+
you can add special annotations that when run through RunDOC can
|
66
94
|
generate a project.
|
67
95
|
|
68
|
-
All
|
96
|
+
All RunDOC commands are prefixed with three colons `:::` and are inclosed in a code block a
|
69
97
|
command such as `$` which is an alias for `bash` commands like this:
|
70
98
|
|
71
99
|
```
|
72
|
-
|
100
|
+
:::>- $ git init .
|
73
101
|
```
|
74
102
|
|
75
103
|
Nothing before the three colons matters. The space between the colons
|
@@ -80,7 +108,7 @@ can add a minus symbol `-` to the end to prevent it from being
|
|
80
108
|
rendered.
|
81
109
|
|
82
110
|
```
|
83
|
-
|
111
|
+
:::-- $ git init .
|
84
112
|
```
|
85
113
|
|
86
114
|
> Note: If all commands inside of a code block are hidden, the entire codeblock will not be rendered.
|
@@ -100,26 +128,7 @@ This code block might generate an output something like this to your markdown do
|
|
100
128
|
Gemfile.lock Rakefile config db lib public test vendor
|
101
129
|
```
|
102
130
|
|
103
|
-
|
104
|
-
|
105
|
-
## Rendering Cheat Sheet
|
106
|
-
|
107
|
-
An arrow `>` is shorthand for "render this" and a dash `-` is shorthand for skip this section. The posions two positions are command first and result second. You can skip a trailing `-`.
|
108
|
-
|
109
|
-
|
110
|
-
- `:::>` (yes command, not result)
|
111
|
-
- `:::>>` (yes command, yes result)
|
112
|
-
- `:::-` (not command, not result)
|
113
|
-
- `:::->` (not command, yes result)
|
114
|
-
|
115
|
-
## Shell Commands
|
116
|
-
|
117
|
-
Current Commands:
|
118
|
-
|
119
|
-
- `$`
|
120
|
-
- `fail.$`
|
121
|
-
|
122
|
-
Anything you pass to `$` will be run in a shell. Any items below the command will be passed into the stdin of the bash command so:
|
131
|
+
Any items below the command will be passed into the stdin of the command. For example using a `$` command you can effectively pipe contents to stdin:
|
123
132
|
|
124
133
|
```
|
125
134
|
:::>> $ tail -n 2
|
@@ -139,7 +148,76 @@ Would output:
|
|
139
148
|
|
140
149
|
This STDIN feature could be useful if you are running an interactive command such as `play new` which requires user input. For more fine grained input you'll need to use a custom repl object (will be covered later).
|
141
150
|
|
142
|
-
|
151
|
+
Different commands will do different things with this input. For example the `rundoc` command executes Ruby configuration code:
|
152
|
+
|
153
|
+
```
|
154
|
+
:::-- rundoc
|
155
|
+
Rundoc.configure do |config|
|
156
|
+
config.after_build do
|
157
|
+
puts "you could push to GitHub here"
|
158
|
+
puts "You could do anything here"
|
159
|
+
puts "This code will run after the docs are done building"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
```
|
163
|
+
|
164
|
+
|
165
|
+
And the `website.visit` command allows you to navigate and manipulate a webpage via a Capybara API:
|
166
|
+
|
167
|
+
```
|
168
|
+
:::>> website.visit(name: "localhost", url: "http://localhost:3000", scroll: 100)
|
169
|
+
session.execute_script "window.scrollBy(0,100)"
|
170
|
+
session.click("sign up")
|
171
|
+
```
|
172
|
+
|
173
|
+
### Exact output
|
174
|
+
|
175
|
+
RunDOC only cares about things that come after a `:::` section. If you have a "regular" code section, it will be rendered as as normal:
|
176
|
+
|
177
|
+
```
|
178
|
+
$ echo "I won't run since i'm missing the :::>> at the front"
|
179
|
+
```
|
180
|
+
|
181
|
+
You can mix non-command code and commands, as long as the things that aren't rendering come first. This can be used to "fake" a command, for example:
|
182
|
+
|
183
|
+
```
|
184
|
+
$ rails new myapp # Not a command since it's missing the ":::>>""
|
185
|
+
:::-> $ rails new myapp --skip-test --skip-yarn --skip-sprockets
|
186
|
+
:::>> | $ head -n 5
|
187
|
+
```
|
188
|
+
|
189
|
+
This will render as:
|
190
|
+
|
191
|
+
```
|
192
|
+
$ rails new myapp # Not a command since it's missing the ":::>>""
|
193
|
+
create
|
194
|
+
create README.md
|
195
|
+
create Rakefile
|
196
|
+
create .ruby-version
|
197
|
+
create config.ru
|
198
|
+
```
|
199
|
+
|
200
|
+
It looks like the command was run without any flags, but in reality `rails new myapp --skip-test --skip-yarn --skip-sprockets | head -n 5` was executed.
|
201
|
+
|
202
|
+
## Rendering Cheat Sheet
|
203
|
+
|
204
|
+
An arrow `>` is shorthand for "render this" and a dash `-` is shorthand for skip this section. The two positions are **command** first and **result** second.
|
205
|
+
|
206
|
+
|
207
|
+
- `:::>-` (YES command output, not result output)
|
208
|
+
- `:::>>` (YES command output, YES result output)
|
209
|
+
- `:::--` (not command output, not result output)
|
210
|
+
- `:::->` (not command output, YES result output)
|
211
|
+
|
212
|
+
## Shell Commands
|
213
|
+
|
214
|
+
Current Commands:
|
215
|
+
|
216
|
+
- `$`
|
217
|
+
- `fail.$`
|
218
|
+
|
219
|
+
Anything you pass to `$` will be run in a shell. If a shell command returns a non-zero exit status an error will be raised. If you expect a non-zero exit status use `fail.$` instead:
|
220
|
+
|
143
221
|
|
144
222
|
```
|
145
223
|
:::>> fail.$ cat /dev/null/foo
|
@@ -164,7 +242,8 @@ Some commands may be custom, for example when running `cd` you likely want to ch
|
|
164
242
|
However this command would fall on its face:
|
165
243
|
|
166
244
|
```
|
167
|
-
:::>> $ cd myapp
|
245
|
+
:::>> $ cd myapp && cat config/database.yml
|
246
|
+
:::>> $ rails g scaffold users # <=== This command would be in the wrong directory, not `myapp`
|
168
247
|
```
|
169
248
|
|
170
249
|
These custom commands are kept to a minimum, and for the most part behave as you would expect them to. Write your docs as you normally would and check the output frequently.
|
@@ -179,10 +258,10 @@ Current Commands:
|
|
179
258
|
- `file.append`
|
180
259
|
- `file.remove`
|
181
260
|
|
182
|
-
Use the `file.write` keyword followed by a filename, on the next line(s) put the contents of the file
|
261
|
+
Use the `file.write` keyword followed by a filename, on the next line(s) put the contents of the file:
|
183
262
|
|
184
263
|
```
|
185
|
-
|
264
|
+
:::>- file.write config/routes.rb
|
186
265
|
|
187
266
|
Example::Application.routes.draw do
|
188
267
|
root :to => "pages#index"
|
@@ -193,10 +272,12 @@ Use the `file.write` keyword followed by a filename, on the next line(s) put the
|
|
193
272
|
end
|
194
273
|
```
|
195
274
|
|
275
|
+
> If the exact filename is not known you can use a [file glob (\*)](https://GitHub.com/schneems/rundoc/pull/6).
|
276
|
+
|
196
277
|
If you wanted to change `users` to `products` you could write to the same file again.
|
197
278
|
|
198
279
|
```
|
199
|
-
|
280
|
+
:::>- file.write config/routes.rb
|
200
281
|
Example::Application.routes.draw do
|
201
282
|
root :to => "pages#index"
|
202
283
|
|
@@ -256,27 +337,140 @@ Anything after the pipe `|` will generate a new command with the output of the p
|
|
256
337
|
|
257
338
|
This command is currently hacked together, and needs a refactor. Use it, but if something does not behave as you would expected open an issue and explain it.
|
258
339
|
|
340
|
+
## Background
|
341
|
+
|
342
|
+
Sometimes you want to start a long lived process like a server in the background. In that case, the `background` namespace has your, well, back.
|
343
|
+
|
344
|
+
To start a process, pass in the command as the first arg, and give it a name (so it can be referenced later):
|
345
|
+
|
346
|
+
```
|
347
|
+
:::>> background.start("rails server", name: "server")
|
348
|
+
```
|
349
|
+
|
350
|
+
You can make the background process wait until it receives a certain string in the logs. For instance to make sure that the server is fully booted:
|
351
|
+
|
352
|
+
```
|
353
|
+
:::>> background.start("rails server", name: "server", wait: "Listening on")
|
354
|
+
```
|
355
|
+
|
356
|
+
You can stop the process by referencing the name:
|
357
|
+
|
358
|
+
```
|
359
|
+
:::-- background.stop(name: "server")
|
360
|
+
```
|
361
|
+
|
362
|
+
You can also get the log contents:
|
363
|
+
|
364
|
+
```
|
365
|
+
:::>> background.log.read(name: "server")
|
366
|
+
```
|
367
|
+
|
368
|
+
You can also truncate the logs:
|
369
|
+
|
370
|
+
```
|
371
|
+
:::>> background.log.clear(name: "server")
|
372
|
+
```
|
373
|
+
|
374
|
+
## Screenshots
|
375
|
+
|
376
|
+
You'll need selenium and `chromedriver` installed on your system to make screenshots work. On a mac you can run:
|
377
|
+
|
378
|
+
```
|
379
|
+
$ brew cask install chromedriver
|
380
|
+
```
|
381
|
+
|
382
|
+
To take a screenshot first "visit" a website. The values you pass in to stdin can be used to further navigate. For more information see the [Capybara DSL](https://www.rubydoc.info/GitHub/teamcapybara/capybara/master#the-dsl). Use the keyword `session`
|
383
|
+
|
384
|
+
Once you're on the page you want to capture you can execute `website.screenshot`:
|
385
|
+
|
386
|
+
```
|
387
|
+
:::>> website.visit(name: "localhost", url: "http://localhost:3000", scroll: 100)
|
388
|
+
session.execute_script "window.scrollBy(0,100)"
|
389
|
+
session.first(:link, "sign up").click
|
390
|
+
|
391
|
+
:::>> website.screenshot(name: "localhost")
|
392
|
+
```
|
393
|
+
|
394
|
+
The result of the screenshot command will be to replace the code section with a markdown link to a relative path of the screenshot.
|
395
|
+
|
396
|
+
Once you've visited a website you can further navigate using `website.nav` or `website.navigate`:
|
397
|
+
|
398
|
+
|
399
|
+
```
|
400
|
+
:::>> website.visit(name: "localhost", url: "http://localhost:3000")
|
401
|
+
:::>> website.navigate(name: "localhost")
|
402
|
+
session.execute_script "window.scrollBy(0,100)"
|
403
|
+
session.first(:link, "sign up").click
|
404
|
+
|
405
|
+
:::>> website.screenshot(name: "localhost")
|
406
|
+
```
|
407
|
+
|
408
|
+
## Upload Screenshots
|
409
|
+
|
410
|
+
You can specify that you want to upload files to S3 instead of hosting them locally by passing in `upload: "s3"` to the screenshot command:
|
411
|
+
|
412
|
+
```
|
413
|
+
:::>> website.visit(name: "localhost", url: "http://localhost:3000", scroll: 100)
|
414
|
+
:::>> website.screenshot(name: "localhost", upload: "s3")
|
415
|
+
```
|
416
|
+
|
417
|
+
To authorize, you'll need to set these environment variables:
|
418
|
+
|
419
|
+
```
|
420
|
+
AWS_ACCESS_KEY_ID
|
421
|
+
AWS_REGION
|
422
|
+
AWS_SECRET_ACCESS_KEY
|
423
|
+
AWS_BUCKET_NAME
|
424
|
+
```
|
425
|
+
|
426
|
+
The bucketeer addon on Heroku is supported out of the box. To specify project specific environment variables see the "dotenv" section below.
|
427
|
+
|
428
|
+
## Compose multiple RunDOC documents
|
429
|
+
|
430
|
+
If you're writing multiple tutorials that all are used together to build one larger project then you can declare dependencies inside of your RunDOC document.
|
431
|
+
|
432
|
+
For example on day two (`day_two/rundoc.md`) of the tutorials you could:
|
433
|
+
|
434
|
+
```
|
435
|
+
:::-- rundoc.depend_on "../day_one/rundoc.md"
|
436
|
+
```
|
437
|
+
|
438
|
+
Now when you build `day_two/rundoc.md` it will also run the steps in `day_one/rundoc.md` first. This way you don't have to copy and paste previous commands.
|
439
|
+
|
440
|
+
You can also break up your document into smaller components:
|
441
|
+
|
442
|
+
|
443
|
+
```
|
444
|
+
:::>> rundoc.require "../shared/rails_new.md"
|
445
|
+
```
|
446
|
+
|
447
|
+
This will replace the code section with the generated contents of `rundoc.require`.
|
448
|
+
|
449
|
+
|
450
|
+
## Dotenv support
|
451
|
+
|
452
|
+
If you need to specify project specific environment variables create a file called `.env` at the same directory as your `rundoc.md` and it will be imported. Add this file to your `.gitignore` so you don't accidentally share with the world
|
259
453
|
|
260
454
|
## Configure
|
261
455
|
|
262
|
-
You can configure your docs in your docs use the `
|
456
|
+
You can configure your docs in your docs use the `RunDOC` command
|
263
457
|
|
264
458
|
```
|
265
|
-
|
459
|
+
:::-- rundoc.configure
|
266
460
|
```
|
267
461
|
|
268
462
|
Note: Make sure you run this as a hidden command (with `-`).
|
269
463
|
|
270
|
-
**
|
464
|
+
**After Build**
|
271
465
|
|
272
466
|
This will eval any code you put under that line (in Ruby). If you want to run some code after you're done building your docs you could use `Rundoc.configure` block and call the `after_build` method like this:
|
273
467
|
|
274
468
|
|
275
469
|
```
|
276
|
-
|
470
|
+
:::-- rundoc.configure
|
277
471
|
Rundoc.configure do |config|
|
278
472
|
config.after_build do
|
279
|
-
puts "you could push to
|
473
|
+
puts "you could push to GitHub here"
|
280
474
|
puts "You could do anything here"
|
281
475
|
puts "This code will run after the docs are done building"
|
282
476
|
end
|
@@ -286,10 +480,10 @@ This will eval any code you put under that line (in Ruby). If you want to run so
|
|
286
480
|
|
287
481
|
**Project Root**
|
288
482
|
|
289
|
-
By default your app builds in a `tmp` directory. If any failures occur the results will remain in `tmp`. On a successful build the contents are copied over to `project`. If you are generating a new rails project in your code `$ rails new myapp`. Then the finished directory would be in `project/myapp`. If you don't like the `./project` prefix you could tell
|
483
|
+
By default your app builds in a `tmp` directory. If any failures occur the results will remain in `tmp`. On a successful build the contents are copied over to `project`. If you are generating a new rails project in your code `$ rails new myapp`. Then the finished directory would be in `project/myapp`. If you don't like the `./project` prefix you could tell RunDOC to output contents in `./myapp` instead.
|
290
484
|
|
291
485
|
```
|
292
|
-
|
486
|
+
:::-- rundoc.configure
|
293
487
|
Rundoc.configure do |config|
|
294
488
|
config.project_root = "myapp"
|
295
489
|
end
|
@@ -302,39 +496,14 @@ This will also be the root directory that the `after_build` is executed in.
|
|
302
496
|
Sometimes sensitive info like usernames, email addresses, or passwords may be introduced to the output readme. Let's say that your email address was `schneems@example.com` you could filter this out of your final document and replace it with `developer@example.com` instead like this:
|
303
497
|
|
304
498
|
```
|
305
|
-
|
499
|
+
:::-- rundoc.configure
|
306
500
|
Rundoc.configure do |config|
|
307
|
-
config.filter_sensitive("schneems@
|
501
|
+
config.filter_sensitive("schneems@example.com" => "developer@example.com")
|
308
502
|
end
|
309
503
|
```
|
310
504
|
|
311
505
|
This command `filter_sensitive` can be called multiple times with different values. Since the config is in Ruby you could iterate over an array of sensitive data
|
312
506
|
|
313
|
-
##
|
314
|
-
|
315
|
-
This is a section for brainstorming. If it's here it's not guaranteed to get worked on, but it will be considered.
|
316
|
-
|
317
|
-
- Seperate parsing from running. This will help for easier linting of syntax etc.
|
318
|
-
- Cache SHAs and output of each code block. If one sha changes, re-generate all code blocks, otherwise allow a re-render without code execution. Configure a check sum for busting the cache for instance a new version of Rails is released.
|
319
|
-
|
320
|
-
|
321
|
-
- A way to run background processes indefinitely such as `rails server`
|
322
|
-
- Maybe a way to truncate them after only a period of time such as grab a few lines of `heroku local`.
|
323
|
-
|
324
|
-
|
325
|
-
```
|
326
|
-
:::> background.start(command: "rails server")
|
327
|
-
```
|
328
|
-
|
329
|
-
```
|
330
|
-
:::>> background.read("rails server")
|
331
|
-
:::> | $ head -n 23
|
332
|
-
:::> background.clear
|
333
|
-
```
|
334
|
-
|
507
|
+
## Copyright
|
335
508
|
|
336
|
-
|
337
|
-
- Better line matching for backtrace
|
338
|
-
- `-=` command (runs command, only shows output, does not show command) ?
|
339
|
-
- An easy test syntax?
|
340
|
-
- Screenshot tool(s) ?!?!?!?!?!?! :)
|
509
|
+
All content Copyright Richard Schneeman © 2020
|