Migrate v3 preview to VuePress 1.x (#1233)

Cleanup processing for preview - e.g. no previous versions

Signed-off-by: Yannick Schaus <github@schaus.net>
pull/1265/head
Yannick Schaus 2020-05-25 13:42:37 +02:00 committed by GitHub
parent 22962ee786
commit 5348b22a2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 4631 additions and 6145 deletions

View File

@ -3,7 +3,6 @@ const DocsSidebarNavigation = require('./docs-sidebar.js')
const fs = require ('fs-extra')
const path = require('path')
// const CopyWebpackPlugin = require('copy-webpack-plugin')
const vuepressTabs = require('vuepress-tabs')
const HighlightDsl = require('./highlight-dsl')
const HighlightRules = require('./highlight-rules')
@ -15,8 +14,8 @@ module.exports = {
description: 'This is a preview of the main parts of the documentation, found in the openhab/openhab-docs repository',
dest: 'vuepress',
host: 'localhost',
plugins: ['tabs', 'container'],
base,
shouldPrefetch: () => false,
head: [
['link', { rel: 'stylesheet', href: `/fonts/fonts.css` }],
['link', { rel: 'icon', href: `/favicon.ico` }],
@ -29,42 +28,39 @@ module.exports = {
// ['meta', { property: 'og:description', content: 'a vendor and technology agnostic open source automation software for your home' }],
// ['script', { src: `https://identity.netlify.com/v1/netlify-identity-widget.js` }]
],
markdown: {
config: (md) => {
vuepressTabs(md)
md.options.linkify = true
const highlight = md.options.highlight
md.options.highlight = (str, lang) => {
if (!Prism.languages.dsl || !Prism.languages.rules) {
Prism.languages.dsl = HighlightDsl
Prism.languages.rules = HighlightRules
}
if (['nginx', 'bash', 'python', 'js', 'javascript', 'groovy'].indexOf(lang) >= 0) return highlight(str, lang)
/* Simple heuristics to detect rules & other openHAB DSL code snippets and override the language */
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/)) {
lang = 'dsl'
}
if (str.match(/\b(?:String|DateTime)\b/) && lang !== 'java' && lang !== 'xml') {
lang = 'dsl'
}
if ((str.match(/\brule\b/) && str.match(/\bwhen\b/) && str.match(/\bthen\b/) && str.match(/\bend\b/)) ||
str.match(/received update/) || str.match(/changed.*(?:from|to)/) || str.match(/Channel.*triggered/) ||
str.match(/\bval\b/) || str.match(/\bvar\b/) /* <-- dangerous! */) {
lang = 'rules'
}
if (lang === 'shell' || lang === 'sh' || lang === 'shell_session') lang = 'bash'
if (lang === 'conf') lang = 'dsl'
if (lang === 'JSON') lang = 'json'
// if (lang === 'xtend' || lang === 'text' || !lang) {
// console.log('Cannot determine language of code: ' + lang)
// console.log(str)
// }
return highlight(str, lang)
extendMarkdown(md) {
md.options.linkify = true
const highlight = md.options.highlight
md.options.highlight = (str, lang) => {
if (!Prism.languages.dsl || !Prism.languages.rules) {
Prism.languages.dsl = HighlightDsl
Prism.languages.rules = HighlightRules
}
if (['nginx', 'bash', 'python', 'js', 'javascript', 'groovy'].indexOf(lang) >= 0) return highlight(str, lang)
/* Simple heuristics to detect rules & other openHAB DSL code snippets and override the language */
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/)) {
lang = 'dsl'
}
if (str.match(/\b(?:String|DateTime)\b/) && lang !== 'java' && lang !== 'xml') {
lang = 'dsl'
}
if ((str.match(/\brule\b/) && str.match(/\bwhen\b/) && str.match(/\bthen\b/) && str.match(/\bend\b/)) ||
str.match(/received update/) || str.match(/changed.*(?:from|to)/) || str.match(/Channel.*triggered/) ||
str.match(/\bval\b/) || str.match(/\bvar\b/) /* <-- dangerous! */) {
lang = 'rules'
}
if (lang === 'shell' || lang === 'sh' || lang === 'shell_session') lang = 'bash'
if (lang === 'conf') lang = 'dsl'
if (lang === 'JSON') lang = 'json'
// if (lang === 'xtend' || lang === 'text' || !lang) {
// console.log('Cannot determine language of code: ' + lang)
// console.log(str)
// }
return highlight(str, lang)
}
},
// configureWebpack: (config, isServer) => {

View File

@ -135,6 +135,10 @@ module.exports = [
'developer/contributing',
'developer/governance',
'developer/legacy/compatibilitylayer',
{
title: 'Javadoc',
path: 'https://next.openhab.org/javadoc/latest/'
}
]
},
]

View File

@ -146,27 +146,6 @@ def process_file(indir, file, outdir, source)
end
end
if !in_frontmatter && line =~ /^# / then
# Put a warning banner for obsolete bindings
out.puts line
if obsolete_binding then
out.puts
out.puts "::: danger OBSOLETE BINDING"
new_addon = file.split('/')[0].gsub('1', '')
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."
out.puts ":::"
out.puts
obsolete_binding = false
end
# Add the logo if specified
if has_logo then
out.puts
out.puts '<AddonLogo/>'
has_logo = false
end
next
end
# Expand <!--list-subs--> comments with a list of links
# (https://github.com/eclipse/smarthome/issues/5571)
if line =~ /<!--\s*list-subs\s*-->/ then
@ -233,7 +212,6 @@ def process_file(indir, file, outdir, source)
# Add the components for the versions dropdown and the edit link
out.puts
out.puts '<DocPreviousVersions/>' unless file == "introduction.md" and outdir == "docs"
out.puts '<EditPageLink/>'
}
end

View File

@ -1,4 +1,4 @@
@require '~vuepress-tabs/dist/themes/default.styl'
@require '~vuepress-plugin-tabs/dist/themes/default.styl'
.navbar:not(.headroom--top):not(.transparent)
box-shadow rgba(10%,10%,10%,25%) 0 0 10px
@ -35,6 +35,12 @@
font-weight 400
font-size 1rem
.nav-item .dropdown-title
// font-family 'Open Sans', sans-serif
font-weight 400
font-size 1rem
color inherit !important
.dropdown-subitem .nav-link a
font-weight normal
@ -55,19 +61,19 @@
@media (min-width: 720px) and (max-width: 1023px)
.search-box input:focus
width: 10.8rem // to cover the openHAB text (leaving the logo)
width: 10.8rem !important // to cover the openHAB text (leaving the logo)
@media (min-width: 1024px) and (max-width: 1280px)
.search-box input
width: 5.7rem
width: 5.7rem !important
@media (max-width: 360px)
.search-box input:focus
width: 9.4rem // to cover the openHAB text (leaving the logo)
width: 9.4rem !important // to cover the openHAB text (leaving the logo)
@media (max-width: 419px)
.search-box input:focus
width: 4rem
width: 4rem !important
.content:not(.custom)>h1:first-child
font-family 'Open Sans', sans-serif
@ -86,29 +92,26 @@
overflow hidden !important
white-space pre-wrap !important
.content:not(.custom), .page-nav
.theme-default-content:not(.custom), .page-nav
max-width 1280px !important
.page .content:not(.custom):not(.page-nav):not(.edit-link)
.page .theme-default-content:not(.custom):not(.page-nav):not(.edit-link)
min-height 85vh !important
.page .content.edit-link
.page .page-edit
display none
.logo
width 160px
height 35px
a[href*='.openhab.org'] .outbound
display none
.nav-item > a.external:hover
border-bottom 2px solid #ff7214
.custom-block.tip
border-color #2196f3 !important
/* Tweaks for vuepress-tabs */
/* Tweaks for vuepress-plugin-tabs */
.vuepress-tabs
.tabs-component

View File

@ -2,3 +2,4 @@ $accentColor = #ff6600
$MQMobile = 859px
$MQNarrow = 1023px
$headerColor = #000

10642
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "openhab-docs",
"version": "1.0.0",
"version": "3.0.0",
"description": "openHAB Documentation",
"main": "index.js",
"scripts": {
@ -13,15 +13,16 @@
"url": "git+https://github.com/openhab/openhab-docs.git"
},
"author": "",
"license": "EPL-1.0",
"license": "EPL-2.0",
"bugs": {
"url": "https://github.com/openhab/openhab-docs/issues"
},
"homepage": "https://github.com/openhab/openhab-docs#readme",
"dependencies": {
"vue-tabs-component": "^1.5.0",
"vuepress": "^0.14.11",
"vuepress-tabs": "^0.1.6",
"vuepress": "^1.5.0",
"vuepress-plugin-container": "^2.1.4",
"vuepress-plugin-tabs": "^0.3.0",
"webpack-serve": "^3.1.1"
}
}

View File

@ -36,6 +36,7 @@ add_placeholder_pages()
if (ARGV[0] && ARGV[0] == "--delete-sources") then
puts ">>> !!! Deleting source files - for ephemeral clones only!"
FileUtils.rm_rf(Dir.glob("addons/*.md"))
["administration", "appendix", "community", "configuration", "developers", "installation", "tutorials"].each { |d|
FileUtils.rm_rf(d)
}