Skip to content

Commit 5348b22

Browse files
authored
Migrate v3 preview to VuePress 1.x (openhab#1233)
Cleanup processing for preview - e.g. no previous versions Signed-off-by: Yannick Schaus <[email protected]>
1 parent 22962ee commit 5348b22

8 files changed

+4864
-6378
lines changed

.vuepress/config.js

+31-35
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const DocsSidebarNavigation = require('./docs-sidebar.js')
33
const fs = require ('fs-extra')
44
const path = require('path')
55
// const CopyWebpackPlugin = require('copy-webpack-plugin')
6-
const vuepressTabs = require('vuepress-tabs')
76

87
const HighlightDsl = require('./highlight-dsl')
98
const HighlightRules = require('./highlight-rules')
@@ -15,8 +14,8 @@ module.exports = {
1514
description: 'This is a preview of the main parts of the documentation, found in the openhab/openhab-docs repository',
1615
dest: 'vuepress',
1716
host: 'localhost',
17+
plugins: ['tabs', 'container'],
1818
base,
19-
shouldPrefetch: () => false,
2019
head: [
2120
['link', { rel: 'stylesheet', href: `/fonts/fonts.css` }],
2221
['link', { rel: 'icon', href: `/favicon.ico` }],
@@ -29,42 +28,39 @@ module.exports = {
2928
// ['meta', { property: 'og:description', content: 'a vendor and technology agnostic open source automation software for your home' }],
3029
// ['script', { src: `https://identity.netlify.com/v1/netlify-identity-widget.js` }]
3130
],
32-
markdown: {
33-
config: (md) => {
34-
vuepressTabs(md)
35-
md.options.linkify = true
36-
const highlight = md.options.highlight
37-
md.options.highlight = (str, lang) => {
38-
if (!Prism.languages.dsl || !Prism.languages.rules) {
39-
Prism.languages.dsl = HighlightDsl
40-
Prism.languages.rules = HighlightRules
41-
}
42-
43-
if (['nginx', 'bash', 'python', 'js', 'javascript', 'groovy'].indexOf(lang) >= 0) return highlight(str, lang)
31+
extendMarkdown(md) {
32+
md.options.linkify = true
33+
const highlight = md.options.highlight
34+
md.options.highlight = (str, lang) => {
35+
if (!Prism.languages.dsl || !Prism.languages.rules) {
36+
Prism.languages.dsl = HighlightDsl
37+
Prism.languages.rules = HighlightRules
38+
}
4439

45-
/* Simple heuristics to detect rules & other openHAB DSL code snippets and override the language */
46-
if (str.match(/\b(?:Color|Contact|Dimmer|Group|Number|Player|Rollershutter|Switch|Location|Frame|Default|Text|Group|Selection|Setpoint|Slider|Colorpicker|Chart|Webview|Mapview|Image|Video|Item|Thing|Bridge|Time|Type|Sitemap|sitemap)\b/)) {
47-
lang = 'dsl'
48-
}
49-
if (str.match(/\b(?:String|DateTime)\b/) && lang !== 'java' && lang !== 'xml') {
50-
lang = 'dsl'
51-
}
52-
if ((str.match(/\brule\b/) && str.match(/\bwhen\b/) && str.match(/\bthen\b/) && str.match(/\bend\b/)) ||
53-
str.match(/received update/) || str.match(/changed.*(?:from|to)/) || str.match(/Channel.*triggered/) ||
54-
str.match(/\bval\b/) || str.match(/\bvar\b/) /* <-- dangerous! */) {
55-
56-
lang = 'rules'
57-
}
58-
if (lang === 'shell' || lang === 'sh' || lang === 'shell_session') lang = 'bash'
59-
if (lang === 'conf') lang = 'dsl'
60-
if (lang === 'JSON') lang = 'json'
61-
// if (lang === 'xtend' || lang === 'text' || !lang) {
62-
// console.log('Cannot determine language of code: ' + lang)
63-
// console.log(str)
64-
// }
40+
if (['nginx', 'bash', 'python', 'js', 'javascript', 'groovy'].indexOf(lang) >= 0) return highlight(str, lang)
6541

66-
return highlight(str, lang)
42+
/* Simple heuristics to detect rules & other openHAB DSL code snippets and override the language */
43+
if (str.match(/\b(?:Color|Contact|Dimmer|Group|Number|Player|Rollershutter|Switch|Location|Frame|Default|Text|Group|Selection|Setpoint|Slider|Colorpicker|Chart|Webview|Mapview|Image|Video|Item|Thing|Bridge|Time|Type|Sitemap|sitemap)\b/)) {
44+
lang = 'dsl'
45+
}
46+
if (str.match(/\b(?:String|DateTime)\b/) && lang !== 'java' && lang !== 'xml') {
47+
lang = 'dsl'
6748
}
49+
if ((str.match(/\brule\b/) && str.match(/\bwhen\b/) && str.match(/\bthen\b/) && str.match(/\bend\b/)) ||
50+
str.match(/received update/) || str.match(/changed.*(?:from|to)/) || str.match(/Channel.*triggered/) ||
51+
str.match(/\bval\b/) || str.match(/\bvar\b/) /* <-- dangerous! */) {
52+
53+
lang = 'rules'
54+
}
55+
if (lang === 'shell' || lang === 'sh' || lang === 'shell_session') lang = 'bash'
56+
if (lang === 'conf') lang = 'dsl'
57+
if (lang === 'JSON') lang = 'json'
58+
// if (lang === 'xtend' || lang === 'text' || !lang) {
59+
// console.log('Cannot determine language of code: ' + lang)
60+
// console.log(str)
61+
// }
62+
63+
return highlight(str, lang)
6864
}
6965
},
7066
// configureWebpack: (config, isServer) => {

.vuepress/docs-sidebar.js

+4
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ module.exports = [
135135
'developer/contributing',
136136
'developer/governance',
137137
'developer/legacy/compatibilitylayer',
138+
{
139+
title: 'Javadoc',
140+
path: 'https://next.openhab.org/javadoc/latest/'
141+
}
138142
]
139143
},
140144
]

.vuepress/process_file.rb

-22
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,6 @@ def process_file(indir, file, outdir, source)
146146
end
147147
end
148148

149-
if !in_frontmatter && line =~ /^# / then
150-
# Put a warning banner for obsolete bindings
151-
out.puts line
152-
if obsolete_binding then
153-
out.puts
154-
out.puts "::: danger OBSOLETE BINDING"
155-
new_addon = file.split('/')[0].gsub('1', '')
156-
out.puts "This 1.x binding is obsolete; it has been replaced by the 2.x [#{new_addon}](../#{new_addon}/) binding which you should use instead."
157-
out.puts ":::"
158-
out.puts
159-
obsolete_binding = false
160-
end
161-
# Add the logo if specified
162-
if has_logo then
163-
out.puts
164-
out.puts '<AddonLogo/>'
165-
has_logo = false
166-
end
167-
next
168-
end
169-
170149
# Expand <!--list-subs--> comments with a list of links
171150
# (https://github.com/eclipse/smarthome/issues/5571)
172151
if line =~ /<!--\s*list-subs\s*-->/ then
@@ -233,7 +212,6 @@ def process_file(indir, file, outdir, source)
233212

234213
# Add the components for the versions dropdown and the edit link
235214
out.puts
236-
out.puts '<DocPreviousVersions/>' unless file == "introduction.md" and outdir == "docs"
237215
out.puts '<EditPageLink/>'
238216
}
239217
end

.vuepress/style.styl .vuepress/styles/index.styl

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@require '~vuepress-tabs/dist/themes/default.styl'
1+
@require '~vuepress-plugin-tabs/dist/themes/default.styl'
22

33
.navbar:not(.headroom--top):not(.transparent)
44
box-shadow rgba(10%,10%,10%,25%) 0 0 10px
@@ -35,6 +35,12 @@
3535
font-weight 400
3636
font-size 1rem
3737

38+
.nav-item .dropdown-title
39+
// font-family 'Open Sans', sans-serif
40+
font-weight 400
41+
font-size 1rem
42+
color inherit !important
43+
3844
.dropdown-subitem .nav-link a
3945
font-weight normal
4046

@@ -55,19 +61,19 @@
5561

5662
@media (min-width: 720px) and (max-width: 1023px)
5763
.search-box input:focus
58-
width: 10.8rem // to cover the openHAB text (leaving the logo)
64+
width: 10.8rem !important // to cover the openHAB text (leaving the logo)
5965

6066
@media (min-width: 1024px) and (max-width: 1280px)
6167
.search-box input
62-
width: 5.7rem
68+
width: 5.7rem !important
6369

6470
@media (max-width: 360px)
6571
.search-box input:focus
66-
width: 9.4rem // to cover the openHAB text (leaving the logo)
72+
width: 9.4rem !important // to cover the openHAB text (leaving the logo)
6773

6874
@media (max-width: 419px)
6975
.search-box input:focus
70-
width: 4rem
76+
width: 4rem !important
7177

7278
.content:not(.custom)>h1:first-child
7379
font-family 'Open Sans', sans-serif
@@ -86,29 +92,26 @@
8692
overflow hidden !important
8793
white-space pre-wrap !important
8894

89-
.content:not(.custom), .page-nav
95+
.theme-default-content:not(.custom), .page-nav
9096
max-width 1280px !important
9197

92-
.page .content:not(.custom):not(.page-nav):not(.edit-link)
98+
.page .theme-default-content:not(.custom):not(.page-nav):not(.edit-link)
9399
min-height 85vh !important
94100

95-
.page .content.edit-link
101+
.page .page-edit
96102
display none
97103

98104
.logo
99105
width 160px
100106
height 35px
101107

102-
a[href*='.openhab.org'] .outbound
103-
display none
104-
105108
.nav-item > a.external:hover
106109
border-bottom 2px solid #ff7214
107110

108111
.custom-block.tip
109112
border-color #2196f3 !important
110113

111-
/* Tweaks for vuepress-tabs */
114+
/* Tweaks for vuepress-plugin-tabs */
112115

113116
.vuepress-tabs
114117
.tabs-component

.vuepress/override.styl .vuepress/styles/palette.styl

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ $accentColor = #ff6600
22
$MQMobile = 859px
33
$MQNarrow = 1023px
44

5+
$headerColor = #000

0 commit comments

Comments
 (0)