Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe how to use build artifact from a docu repo PR to create the webpage #456

Merged
merged 32 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
836ee83
Describe how to use build artifact from a docu repo PR to create the …
pgfeller Mar 6, 2024
262fa0a
Describe how to use build artifact from a docu repo PR to create the …
pgfeller Mar 6, 2024
a2f8000
checkout PR code added ...
pgfeller Mar 6, 2024
f3ec2c5
Describe how to use build artifact from a docu repo PR to create the …
pgfeller Mar 6, 2024
6ba0a84
bug fix
pgfeller Mar 6, 2024
8cd7d64
Describe how to use build artifact from a docu repo PR to create the …
pgfeller Mar 6, 2024
3949899
... bugfix
pgfeller Mar 6, 2024
ca80b18
Describe how to use build artifact from a docu repo PR to create the …
pgfeller Mar 10, 2024
ac68a2a
Update CONTRIBUTION.md
pgfeller Mar 10, 2024
20ccda1
...
pgfeller Mar 10, 2024
3c97348
...
pgfeller Mar 10, 2024
4dda59a
...
pgfeller Mar 10, 2024
3433e97
...
pgfeller Mar 10, 2024
a999a52
...
pgfeller Mar 10, 2024
a6239bc
...
pgfeller Mar 10, 2024
068d6b1
.md updated ...
pgfeller Mar 10, 2024
55e1539
...
pgfeller Mar 10, 2024
e39a358
...
pgfeller Mar 10, 2024
6da4f87
refactor(review): 🗨️ worked on code review comments
pgfeller Mar 27, 2024
0444bfb
💄cosmetics (--verbose mode), added .nvmrc for user of node version ma…
pgfeller Mar 27, 2024
2dd6f87
Align styling of iconset generation output
florian-h05 Mar 29, 2024
71852df
Fix typo
florian-h05 Mar 29, 2024
e22e27b
Fix script clones even though --no-clone is set
florian-h05 Mar 29, 2024
610aae1
Fix issue with the old setting section that has been removed
florian-h05 Mar 29, 2024
3d0336f
Minor clean-up
florian-h05 Mar 29, 2024
a2f84e9
Various minor wording improvements
florian-h05 Mar 29, 2024
af4510c
Skip all add-on docs for PR build
florian-h05 Mar 29, 2024
49b34d5
Minor code improvements
florian-h05 Mar 29, 2024
4543f6e
Use final as default version similar to it being default branch
florian-h05 Mar 29, 2024
25cd07c
Output formatting improvements
florian-h05 Mar 29, 2024
4732031
refactor(review): 🗨️ processed code review comments
pgfeller Mar 31, 2024
39b23a7
Update add-blog-meta.rb
pgfeller Mar 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Describe how to use build artifact from a docu repo PR to create the …
…webpage

Fixes #455

Signed-off-by: Patrik Gfeller <patrik.gfeller@gmail.com>
pgfeller committed Mar 29, 2024
commit 836ee831464770fecb8d3a354340cbd6902dc7b6
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"editor.tabSize": 2
"editor.tabSize": 2,
"editor.formatOnSave": true,
"[ruby]": {
"editor.defaultFormatter": "testdouble.vscode-standard-ruby"
}
}
7,437 changes: 1,636 additions & 5,801 deletions package-lock.json
pgfeller marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -28,14 +28,15 @@
"scripts": {
"predev": "npm install && npx update-browserslist-db@latest",
"dev": "npx vuepress dev",
"prepare-docs": "ruby prepare-docs.rb",
"prepare-docs": "ruby prepare-docs.rb $ARGUMENTS",
"add-blog-meta": "ruby add-blog-meta.rb",
"build": "ruby prepare-docs.rb && ruby add-blog-meta.rb && vuepress build .",
"build-only": "vuepress build .",
"build-local": "rm -f javadoc-*.tgz* && npm run prepare-docs && npm run dev",
"prebuild-local": "npm run prepare-docs",
pgfeller marked this conversation as resolved.
Show resolved Hide resolved
"build-local": "npm run dev --silenrgit",
"build-local-latest": "OH_DOCS_VERSION=final npm run build-local",
"build-local-stable": "OH_DOCS_VERSION=final-stable npm run build-local"
},
"author": "openHAB",
"license": "EPL-2.0"
}
}
100 changes: 66 additions & 34 deletions prepare-docs.rb
Original file line number Diff line number Diff line change
@@ -15,20 +15,52 @@

$ignore_addons = ['transport.modbus', 'transport.feed', 'javasound', 'webaudio', 'oh2']

puts "🧹 cleaning existing documentation downloads ..."
Dir.glob("javadoc-*.tgz*").select { |file| /pattern/.match file }.each { |file| File.delete(file) }

$parameter_no_clone = false
$pull_request = ""

previous_argument = "";
ARGV.each do |arg|
case arg
when "--no-clone"
$parameter_no_clone = true
puts " --no-clone ➡️ existing clone will be used"
else
case previous_argument
when "--pull-request"
$pull_request = arg
puts "➡️ PR #{arg} will be used to build documentation"
end
end
previous_argument = arg
end


if ENV["OH_DOCS_VERSION"] then
puts ">>> Generating docs for version #{ENV["OH_DOCS_VERSION"]}"
puts "➡️ Generating docs for version #{ENV["OH_DOCS_VERSION"]}"
$version = ENV["OH_DOCS_VERSION"]
$version += ".0" if $version.split(".").length == 2
end

if (ARGV[0] && ARGV[0] == "--no-clone" && Dir.exists?(".vuepress/openhab-docs")) then
puts ">>> Re-using existing clone"

if ($parameter_no_clone && Dir.exists?(".vuepress/openhab-docs")) then
puts "➡️ Re-using existing clone"
else
puts ">>> Deleting .vuepress/openhab-docs if existing..."
puts "➡️ Deleting .vuepress/openhab-docs if existing..."
FileUtils.rm_rf(".vuepress/openhab-docs")
end

puts ">>> Cloning openhab-docs"
`git clone --depth 1 --branch #{$version ? $version : $docs_repo_branch} https://github.com/openhab/openhab-docs .vuepress/openhab-docs`
puts "➡️ Cloning openhab-docs"
if ($pull_request != "") then
Dir.mkdir(".vuepress/openhab-docs")
system(`gh pr checkout #{$pull_request} --repo=#{$docs_repo}`, chdir: '.vuepress/openhab-docs')
# Dir.chdir(".vuepress/openhab-docs") do
# system `gh pr checkout #{$pull_request} --repo=#{$docs_repo}`
# end
else
`git clone --depth 1 --branch #{$version ? $version : $docs_repo_branch} #{$docs_repo} .vuepress/openhab-docs`
end

# Get a list of sub-addons to transform them into links
@@ -282,22 +314,22 @@ def process_file(indir, file, outdir, source)
}
end

puts ">>> Migrating the introduction article"
puts "➡️ Migrating the introduction article"
process_file(".vuepress/openhab-docs", "introduction.md", "docs", "https://github.com/openhab/openhab-docs/blob/main/introduction.md")
FileUtils.mv("docs/introduction.md", "docs/readme.md")


puts ">>> Migrating common images"
puts "➡️ Migrating common images"
FileUtils.mkdir_p("docs/images")
FileUtils.cp_r(".vuepress/openhab-docs/images/distro.png", "docs/images")
FileUtils.cp_r(".vuepress/openhab-docs/images/dashboard.png", "docs/images")


puts ">>> Migrating logos"
puts "➡️ Migrating logos"
FileUtils.cp_r(".vuepress/openhab-docs/images/addons", ".vuepress/public/logos")


puts ">>> Migrating the Concepts section"
puts "➡️ Migrating the Concepts section"
Dir.glob(".vuepress/openhab-docs/concepts/*.md").each { |path|
file = File.basename(path)
puts " -> #{file}"
@@ -308,7 +340,7 @@ def process_file(indir, file, outdir, source)
FileUtils.cp_r(".vuepress/openhab-docs/concepts/diagrams", "docs/concepts")


puts ">>> Migrating the Installation section"
puts "➡️ Migrating the Installation section"
Dir.glob(".vuepress/openhab-docs/installation/*.md") { |path|
file = File.basename(path)
next if file == "designer.md"
@@ -319,7 +351,7 @@ def process_file(indir, file, outdir, source)
FileUtils.cp_r(".vuepress/openhab-docs/installation/images", "docs/installation")


puts ">>> Migrating the Tutorial section"
puts "➡️ Migrating the Tutorial section"
Dir.glob(".vuepress/openhab-docs/tutorials/getting_started/*.md") { |path|
file = File.basename(path)
puts " -> #{file}"
@@ -328,7 +360,7 @@ def process_file(indir, file, outdir, source)
puts " -> images"
FileUtils.cp_r(".vuepress/openhab-docs/tutorials/getting_started/images", "docs/tutorial")

puts ">>> Migrating the Configuration section"
puts "➡️ Migrating the Configuration section"
Dir.glob(".vuepress/openhab-docs/configuration/*.md") { |path|
file = File.basename(path)
next if file == "transform.md" # Useless, copy the one from addons
@@ -348,7 +380,7 @@ def process_file(indir, file, outdir, source)
# Additional files and images for the latest docs
if $version == "final" then

puts ">>> Migrating the Main UI section"
puts "➡️ Migrating the Main UI section"
Dir.glob(".vuepress/openhab-docs/mainui/*.md") { |path|
file = File.basename(path)
puts " -> #{file}"
@@ -366,7 +398,7 @@ def process_file(indir, file, outdir, source)

else
# Additional files and images for the stable docs
puts ">>> Migrating the Settings section"
puts "➡️ Migrating the Settings section"
pgfeller marked this conversation as resolved.
Show resolved Hide resolved
Dir.glob(".vuepress/openhab-docs/settings/*.md") { |path|
file = File.basename(path)
puts " -> #{file}"
@@ -377,7 +409,7 @@ def process_file(indir, file, outdir, source)

end

puts ">>> Migrating the Migration Tutorial section"
puts "➡️ Migrating the Migration Tutorial section"
Dir.glob(".vuepress/openhab-docs/configuration/migration/*.md") { |path|
file = File.basename(path)
puts " -> #{file}"
@@ -387,7 +419,7 @@ def process_file(indir, file, outdir, source)
#FileUtils.cp_r(".vuepress/openhab-docs/configuration/migration/images", "docs/configuration/migration/") // no images placed yet


puts ">>> Migrating the Blockly Tutorial section"
puts "➡️ Migrating the Blockly Tutorial section"
Dir.glob(".vuepress/openhab-docs/configuration/blockly/*.md") { |path|
file = File.basename(path)
puts " -> #{file}"
@@ -397,7 +429,7 @@ def process_file(indir, file, outdir, source)
#FileUtils.cp_r(".vuepress/openhab-docs/configuration/blockly/images", "docs/configuration/blockly/") // no images placed yet


puts ">>> Migrating the UI section"
puts "➡️ Migrating the UI section"
Dir.glob(".vuepress/openhab-docs/ui/*.md") { |path|
file = File.basename(path)
puts " -> #{file}"
@@ -428,7 +460,7 @@ def process_file(indir, file, outdir, source)
FileUtils.cp_r(".vuepress/openhab-docs/_addons_uis/org.openhab.ui/doc/components/images", "docs/ui/components") if Dir.exists?(".vuepress/openhab-docs/_addons_uis/org.openhab.ui/doc/components/images")


puts ">>> Migrating the Apps section"
puts "➡️ Migrating the Apps section"
Dir.glob(".vuepress/openhab-docs/addons/uis/apps/*.md") { |path|
file = File.basename(path)
puts " -> #{file}"
@@ -438,7 +470,7 @@ def process_file(indir, file, outdir, source)
FileUtils.cp_r(".vuepress/openhab-docs/addons/uis/apps/images", "docs/apps")


puts ">>> Migrating the Administration section"
puts "➡️ Migrating the Administration section"
Dir.glob(".vuepress/openhab-docs/administration/*.md") { |path|
file = File.basename(path)
puts " -> #{file}"
@@ -448,7 +480,7 @@ def process_file(indir, file, outdir, source)
FileUtils.cp_r(".vuepress/openhab-docs/administration/images", "docs/administration")


puts ">>> Migrating the Developer section"
puts "➡️ Migrating the Developer section"
Dir.glob(".vuepress/openhab-docs/developers/*.md") { |path|
file = File.basename(path)
puts " -> #{file}"
@@ -488,7 +520,7 @@ def process_file(indir, file, outdir, source)

### ADDONS

puts ">>> Migrating add-ons: Automation"
puts "➡️ Migrating add-ons: Automation"
Dir.glob(".vuepress/openhab-docs/_addons_automation/**") { |path|
addon = File.basename(path)
next if $ignore_addons.include?(addon)
@@ -504,7 +536,7 @@ def process_file(indir, file, outdir, source)
}


puts ">>> Migrating add-ons: Persistence"
puts "➡️ Migrating add-ons: Persistence"
Dir.glob(".vuepress/openhab-docs/_addons_persistences/**") { |path|
addon = File.basename(path)
next if $ignore_addons.include?(addon)
@@ -519,7 +551,7 @@ def process_file(indir, file, outdir, source)
}


puts ">>> Migrating add-ons: Transformations"
puts "➡️ Migrating add-ons: Transformations"
Dir.glob(".vuepress/openhab-docs/_addons_transformations/**") { |path|
addon = File.basename(path)
next if $ignore_addons.include?(addon)
@@ -529,7 +561,7 @@ def process_file(indir, file, outdir, source)
}


puts ">>> Migrating add-ons: Voice"
puts "➡️ Migrating add-ons: Voice"
Dir.glob(".vuepress/openhab-docs/_addons_voices/**") { |path|
addon = File.basename(path)
next if $ignore_addons.include?(addon)
@@ -539,7 +571,7 @@ def process_file(indir, file, outdir, source)
}


puts ">>> Migrating add-ons: IO"
puts "➡️ Migrating add-ons: IO"
Dir.glob(".vuepress/openhab-docs/_addons_ios/**") { |path|
# See below for the Alexa & Mycroft special cases
next if path =~ /alexa-skill/
@@ -567,7 +599,7 @@ def process_file(indir, file, outdir, source)
end
}

puts ">>> Migrating add-ons: UI"
puts "➡️ Migrating add-ons: UI"
Dir.glob(".vuepress/openhab-docs/_addons_uis/**") { |path|
next if path =~ /org.openhab.ui/
addon = File.basename(path)
@@ -584,7 +616,7 @@ def process_file(indir, file, outdir, source)


# Handle those three separately - copy them in the "ecosystem" section
puts ">>> Migrating special ecosystem add-ons"
puts "➡️ Migrating special ecosystem add-ons"
puts " -> Create folders"
FileUtils.mkdir_p("docs/ecosystem/alexa")
FileUtils.mkdir_p("docs/ecosystem/mycroft")
@@ -604,7 +636,7 @@ def process_file(indir, file, outdir, source)
FileUtils.cp_r(".vuepress/openhab-docs/_addons_ios/google-assistant/images", "docs/ecosystem/google-assistant")


puts ">>> Migrating add-ons: Bindings"
puts "➡️ Migrating add-ons: Bindings"
Dir.glob(".vuepress/openhab-docs/_addons_bindings/**") { |path|
addon = File.basename(path)
next if $ignore_addons.include?(addon)
@@ -634,7 +666,7 @@ def process_file(indir, file, outdir, source)



puts ">>> Creating ZWave thing viewer"
puts "➡️ Creating ZWave thing viewer"
if (File.exists?('.vuepress/openhab-docs/_addons_bindings/zwave/doc/things.md')) then
File.open('addons/bindings/zwave/thing.md', 'w+') { |out|
out.puts '---'
@@ -647,7 +679,7 @@ def process_file(indir, file, outdir, source)
end


# puts ">>> Migrating Z-Wave docs"
# puts "➡️ Migrating Z-Wave docs"
# Dir.glob(".vuepress/openhab-docs/_addons_bindings/zwave/doc/*.md") { |path|
# next if path =~ /device\.md/
# file = File.basename(path)
@@ -658,7 +690,7 @@ def process_file(indir, file, outdir, source)


# Write arrays of addons by type to include in VuePress config.js
puts ">>> Writing add-ons arrays to files for sidebar navigation"
puts "➡️ Writing add-ons arrays to files for sidebar navigation"
["bindings", "persistence", "automation", "integrations", "transformations", "voice", "ui"].each { |type|
File.open(".vuepress/addons-#{type}.js", "w+") { |file|
file.puts "module.exports = ["
@@ -682,14 +714,14 @@ def process_file(indir, file, outdir, source)


# Regenerate the classic iconset docs
puts ">>> Generating iconset"
puts "➡️ Generating iconset"
system("ruby generate_iconset_doc.rb .vuepress/openhab-docs/_addons_iconsets classic .vuepress/openhab-docs/_data docs/configuration/iconsets")

# Clean-Ups required for repeated local build
`[ -e javadoc-latest.tar.gz ] && rm javadoc-latest.tar.gz`
`[ -e .vuepress/public/javadoc/latest ] && rm -r .vuepress/public/javadoc/latest`
# Publish latest Javadoc
puts ">>> Downloading and extracting latest Javadoc from Jenkins"
puts "➡️ Downloading and extracting latest Javadoc from Jenkins"
`wget -nv https://ci.openhab.org/job/openHAB-JavaDoc/lastSuccessfulBuild/artifact/target/javadoc-latest.tgz`
`tar xzvf javadoc-latest.tgz --strip 2 && mv apidocs/ .vuepress/public/javadoc/latest`