Skip to content

Commit c64f33b

Browse files
authored
Merge pull request #398 from pact-foundation/chore/update-rust-docs
chore(docs): add rust cli docs to Pact command line tools section
2 parents 3f6da9b + e2f3563 commit c64f33b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+5329
-541
lines changed

.github/workflows/sync-docs.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
- pact-net-docs-updated
1717
- pact-broker-docs-updated
1818
- pact-plugins-docs-updated
19+
- pact-broker-cli-docs-updated
20+
- pact-core-mock-server-docs-updated
21+
- pact-stub-server-docs-updated
22+
- pact-cli-docs-updated
1923
workflow_dispatch:
2024
inputs:
2125
update_event:
@@ -39,6 +43,7 @@ on:
3943
- pact-broker-cli-docs-updated
4044
- pact-core-mock-server-docs-updated
4145
- pact-stub-server-docs-updated
46+
- pact-cli-docs-updated
4247
- all-docs-updated
4348
env:
4449
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -68,15 +73,23 @@ jobs:
6873
- name: Sync Pact Python docs
6974
run: bundle exec scripts/sync/pact_python.rb && echo 'COMMIT_MESSAGE=synced pact-python docs' >> $GITHUB_ENV
7075
if: steps.identify_event.outputs.update_event == 'pact-python-docs-updated'
76+
77+
- name: Sync Pact Broker CLI docs
78+
run: bundle exec scripts/sync/pact_cli.rb && echo 'COMMIT_MESSAGE=synced pact-cli docs' >> $GITHUB_ENV
79+
if: steps.identify_event.outputs.update_event == 'pact-cli-docs-updated'
80+
7181
- name: Sync Pact Broker CLI docs
7282
run: bundle exec scripts/sync/pact_broker_cli.rb && echo 'COMMIT_MESSAGE=synced pact-broker-cli docs' >> $GITHUB_ENV
7383
if: steps.identify_event.outputs.update_event == 'pact-broker-cli-docs-updated'
84+
7485
- name: Sync Pact Core Mock Server docs
75-
run: bundle exec scripts/sync/pact_mock_server.rb && echo 'COMMIT_MESSAGE=synced pact-core-mock-server docs' >> $GITHUB_ENV
86+
run: bundle exec scripts/sync/pact_core_mock_server.rb && echo 'COMMIT_MESSAGE=synced pact-core-mock-server docs' >> $GITHUB_ENV
7687
if: steps.identify_event.outputs.update_event == 'pact-core-mock-server-docs-updated'
88+
7789
- name: Sync Pact Stub Server docs
7890
run: bundle exec scripts/sync/pact_stub_server.rb && echo 'COMMIT_MESSAGE=synced pact-stub-server docs' >> $GITHUB_ENV
7991
if: steps.identify_event.outputs.update_event == 'pact-stub-server-docs-updated'
92+
8093
- name: Sync Pact Go docs
8194
run: bundle exec scripts/sync/pact_go.rb && echo 'COMMIT_MESSAGE=synced pact-go docs' >> $GITHUB_ENV
8295
if: steps.identify_event.outputs.update_event == 'pact-go-docs-updated'

scripts/sync/pact_broker_cli.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require_relative 'support'
33

44
SOURCE_REPO = 'pact-foundation/pact-broker-cli'
5-
DESTINATION_DIR = relative_path_to('docs/implementation_guides/rust')
5+
DESTINATION_DIR = relative_path_to('docs/implementation_guides/cli')
66
TRANSFORM_PATH = -> (path) {
77
if path.downcase.end_with?('changelog.md')
88
File.join(DESTINATION_DIR, "pact-broker-cli", 'changelog.md')
@@ -25,6 +25,9 @@
2525
[->(path) { path.end_with?('README.md') }, ->(md_file_contents) {
2626
md_file_contents.fields[:title] = 'Pact Broker Client'
2727
}],
28+
[->(path) { path }, lambda { |md_file_contents|
29+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/main\n")
30+
}],
2831
]
2932

3033
FileUtils.mkdir_p DESTINATION_DIR

scripts/sync/pact_cli.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env ruby
2+
require_relative 'support'
3+
4+
SOURCE_REPO = 'pact-foundation/pact-cli'
5+
DESTINATION_DIR = relative_path_to('docs/implementation_guides/cli')
6+
TRANSFORM_PATH = -> (path) {
7+
if path.downcase.end_with?('changelog.md')
8+
File.join(DESTINATION_DIR, "pact-cli", 'changelog.md')
9+
else
10+
File.join(DESTINATION_DIR, 'pact-cli.md')
11+
end
12+
}
13+
INCLUDE = [
14+
->(path) { path.end_with?('.md') },
15+
]
16+
IGNORE = [
17+
->(path) { path.include?('docker') }
18+
]
19+
CUSTOM_ACTIONS = [
20+
[->(path) { !path.end_with?('CHANGELOG.md') }, ->(md_file_contents) { md_file_contents.extract_title } ],
21+
[->(path) { path.end_with?('CHANGELOG.md') }, ->(md_file_contents) {
22+
md_file_contents.fields[:title] = 'pact-cli'
23+
md_file_contents.find_and_replace(/^# /, '## ')
24+
}],
25+
[->(path) { path.end_with?('README.md') }, ->(md_file_contents) {
26+
md_file_contents.fields[:title] = 'Pact'
27+
}],
28+
[->(path) { path }, lambda { |md_file_contents|
29+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/main\n")
30+
}],
31+
]
32+
33+
FileUtils.mkdir_p DESTINATION_DIR
34+
35+
sync(SOURCE_REPO, INCLUDE, IGNORE, TRANSFORM_PATH, CUSTOM_ACTIONS, 'main')

scripts/sync/pact_core_mock_server.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33

44
SOURCE_REPO = 'pact-foundation/pact-core-mock-server'
55
DESTINATION_DIR = relative_path_to('docs/implementation_guides/rust')
6+
CLI_DESTINATION_DIR = relative_path_to('docs/implementation_guides/cli')
67
TRANSFORM_PATH = -> (path) {
7-
File.join(DESTINATION_DIR, path.downcase.delete_prefix('rust/').gsub('/readme.md', '.md'))
8+
if path == 'rust/README.md'
9+
"#{DESTINATION_DIR}.md"
10+
elsif path == "pact_mock_server_cli/README.md"
11+
"#{CLI_DESTINATION_DIR}/pact-mock-server.md"
12+
elsif path == "pact_mock_server_cli/CHANGELOG.md"
13+
"#{CLI_DESTINATION_DIR}/pact-mock-server/changelog.md"
14+
else
15+
File.join(DESTINATION_DIR, path.downcase.delete_prefix('rust/').gsub('/readme.md', '.md'))
16+
end
817
}
918
INCLUDE = [
1019
->(path) { path.start_with?('pact_mock_server_cli') && path.end_with?('.md') },
@@ -19,8 +28,13 @@
1928
md_file_contents.find_and_replace(/^# /, '## ')
2029
md_file_contents.find_and_replace(%r{</details>}, '&lt;/details&gt;')
2130
}],
22-
["rust/README.md", ->(md_file_contents) { md_file_contents.fields[:title] = "Overview" } ],
23-
[:all, ->(md_file_contents) { md_file_contents.escape_things_that_look_like_jsx_tags }]
31+
["pact_mock_server_cli/README.md", ->(md_file_contents) { md_file_contents.fields[:title] = "Pact Mock Server" } ],
32+
[:all, ->(md_file_contents) { md_file_contents.escape_things_that_look_like_jsx_tags }],
33+
[->(path) { path.include?('cli') }, lambda { |md_file_contents|
34+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/main/pact_mock_server_cli\n")
35+
}],
36+
[->(path) { path.include?('pact_mock_server/README.md') }, lambda { |md_file_contents| md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/main/pact_mock_server\n") }],
37+
[->(path) { path.include?('pact_mock_server/CHANGELOG.md') }, lambda { |md_file_contents| md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/main/pact_mock_server\n") }],
2438
]
2539

2640

scripts/sync/pact_plugins.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44

55
SOURCE_REPO = 'pact-foundation/pact-plugins'
66
DESTINATION_DIR = relative_path_to('docs/implementation_guides/pact_plugins')
7+
CLI_DESTINATION_DIR = relative_path_to('docs/implementation_guides/cli')
78
TRANSFORM_PATH = lambda { |path|
9+
if path == "cli/README.md"
10+
"#{CLI_DESTINATION_DIR}/pact-plugin.md"
11+
elsif path == "cli/CHANGELOG.md"
12+
"#{CLI_DESTINATION_DIR}/pact-plugin/changelog.md"
13+
else
814
File.join(DESTINATION_DIR, path.downcase)
15+
end
916
}
1017
INCLUDE = [
1118
->(path) { path.end_with?('.md') }
@@ -33,9 +40,15 @@
3340
[->(path) { path.include?('plugins') }, lambda { |md_file_contents|
3441
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/main/plugins\n")
3542
}],
43+
[->(path) { path.include?('cli') }, lambda { |md_file_contents|
44+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/main/cli\n")
45+
}],
3646
[->(path) { path.include?('plugin-driver-design.md') }, lambda { |md_file_contents|
3747
md_file_contents.escape_things_that_look_like_jsx_tags
38-
}]
48+
}],
49+
["cli/README.md", ->(md_file_contents) { md_file_contents.fields[:title] = "Pact Plugin" } ],
50+
["cli/CHANGELOG.md", ->(md_file_contents) { md_file_contents.fields[:title] = "pact-plugin-cli" } ],
51+
3952
]
4053

4154
FileUtils.mkdir_p DESTINATION_DIR

scripts/sync/pact_rust.rb

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@
33

44
SOURCE_REPO = 'pact-foundation/pact-reference'
55
DESTINATION_DIR = relative_path_to('docs/implementation_guides/rust')
6+
CLI_DESTINATION_DIR = relative_path_to('docs/implementation_guides/cli')
67
TRANSFORM_PATH = -> (path) {
78
if path == 'rust/README.md'
89
"#{DESTINATION_DIR}.md"
10+
elsif path == "rust/pact_verifier_cli/README.md"
11+
"#{CLI_DESTINATION_DIR}/pact-verifier.md"
12+
elsif path == "rust/pact_verifier_cli/CHANGELOG.md"
13+
"#{CLI_DESTINATION_DIR}/pact-verifier/changelog.md"
914
else
1015
File.join(DESTINATION_DIR, path.downcase.delete_prefix('rust/').gsub('/readme.md', '.md'))
1116
end
1217
}
1318
INCLUDE = [
14-
# ->(path) { path.end_with?('pact_mock_server_cli/README.md') }
1519
->(path) { path.start_with?('rust') && path.end_with?('.md') }
1620
]
17-
IGNORE = []
21+
IGNORE = [
22+
->(path) { path == 'rust/pact_mock_server/README.md' },
23+
->(path) { path == 'rust/pact_mock_server/CHANGELOG.md' },
24+
->(path) { path == 'rust/pact_mock_server_cli/README.md' },
25+
->(path) { path == 'rust/pact_mock_server_cli/CHANGELOG.md' }
26+
]
1827
CUSTOM_ACTIONS = [
1928
[->(path) { !path.end_with?('CHANGELOG.md') }, ->(md_file_contents) { md_file_contents.extract_title } ],
2029
[->(path) { path.end_with?('CHANGELOG.md') }, ->(md_file_contents) {
@@ -23,7 +32,32 @@
2332
md_file_contents.find_and_replace(/^# /, '## ')
2433
}],
2534
["rust/README.md", ->(md_file_contents) { md_file_contents.fields[:title] = "Overview" } ],
26-
["rust/pact_ffi/README.md", ->(md_file_contents) { md_file_contents.find_and_replace(%r{</details>}, '&lt;/details&gt;') }],
35+
["rust/pact_ffi/README.md", ->(md_file_contents) {
36+
md_file_contents.find_and_replace(%r{</details>}, '&lt;/details&gt;')
37+
md_file_contents.fields[:title] = "README"
38+
}],
39+
["rust/pact_verifier_cli/README.md", ->(md_file_contents) { md_file_contents.fields[:title] = "Pact Verifier" } ],
40+
[->(path) { path.include?('cli') }, lambda { |md_file_contents|
41+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/master/rust/pact_verifier_cli\n")
42+
}],
43+
[->(path) { path.include?('rust/pact_verifier/') }, lambda { |md_file_contents|
44+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/master/rust/pact_verifier\n")
45+
}],
46+
[->(path) { path.include?('rust/pact_consumer/') }, lambda { |md_file_contents|
47+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/master/rust/pact_consumer\n")
48+
}],
49+
[->(path) { path.include?('rust/pact_models/') }, lambda { |md_file_contents|
50+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/master/rust/pact_models\n")
51+
}],
52+
[->(path) { path.include?('rust/pact_matching/') }, lambda { |md_file_contents|
53+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/master/rust/pact_matching\n")
54+
}],
55+
[->(path) { path.include?('rust/pact_ffi/') }, lambda { |md_file_contents|
56+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/master/rust/pact_ffi\n")
57+
}],
58+
[->(path) { path.include?('rust/readme.md') }, lambda { |md_file_contents|
59+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/master/rust\n")
60+
}],
2761
[:all, ->(md_file_contents) { md_file_contents.escape_things_that_look_like_jsx_tags }]
2862
]
2963

scripts/sync/pact_stub_server.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require_relative 'support'
33

44
SOURCE_REPO = 'pact-foundation/pact-stub-server'
5-
DESTINATION_DIR = relative_path_to('docs/implementation_guides/rust')
5+
DESTINATION_DIR = relative_path_to('docs/implementation_guides/cli')
66
TRANSFORM_PATH = -> (path) {
77
if path.downcase.end_with?('changelog.md')
88
File.join(DESTINATION_DIR, "pact-stub-server", 'changelog.md')
@@ -22,8 +22,13 @@
2222
md_file_contents.fields[:title] = "pact-stub-server"
2323
md_file_contents.clean_up_changelog
2424
md_file_contents.find_and_replace(/^# /, '## ')
25-
# md_file_contents.find_and_replace(%r{</details>}, '&lt;/details&gt;')
2625
}],
26+
[->(path) { path.end_with?('README.md') }, ->(md_file_contents) {
27+
md_file_contents.fields[:title] = 'Pact Stub Server'
28+
}],
29+
[->(path) { path }, lambda { |md_file_contents|
30+
md_file_contents.add_lines_at_start("## Source Code\n\nhttps://github.com/#{SOURCE_REPO}/tree/master\n")
31+
}],
2732
]
2833

2934
FileUtils.mkdir_p DESTINATION_DIR

0 commit comments

Comments
 (0)