Skip to content

Commit

Permalink
Merge branch 'release-0.7.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
ghettovoice committed Nov 11, 2017
2 parents eaef67c + cb3e4f5 commit b8d6457
Show file tree
Hide file tree
Showing 128 changed files with 6,930 additions and 3,896 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist-docs/*
test/e2e/reports/*
test/unit/coverage/*
demo/*
out/*
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
extends: 'standard',
// required to lint *.vue files
plugins: [
'node',
'import',
'html',
'lodash-fp',
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,4 @@ test/unit/coverage
dist
lib
dist-docs
out
5 changes: 3 additions & 2 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/dictionaries/ghetto.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion .idea/inspectionProfiles/Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .jsdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
recurseDepth: 10,
plugins: [
'plugins/underscore',
// 'build/jsdoc/inline',
'build/jsdoc/markdown',
'build/jsdoc/vue',
],
source: {
// include: ['./src'],
includePattern: '\\.(vue|js)$',
},
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ npm install -S vue vuelayers
**NOTE**: Node **v6+** is required.

``` bash
git clone https://github.com/ghettovoice/vuelayers.git
git clone --recursive -j8 https://github.com/ghettovoice/vuelayers.git
cd vuelayers

# install dependencies
Expand Down
3 changes: 3 additions & 0 deletions build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ${packageJson.description}
*/`

const BASE_URL = process.env.BASE_URL || '/'
const primaryColor = '#1e88e5'

module.exports = {
banner,
Expand Down Expand Up @@ -47,6 +48,8 @@ module.exports = {
C_PKG_LICENSE_NAME: packageJson.license,
C_BASE_URL: BASE_URL,
C_GOOGLE_UID: 'UA-98870917-3',
C_PRIMARY_COLOR: primaryColor,
},
autoOpenBrowser: true,
themeColor: primaryColor,
}
162 changes: 162 additions & 0 deletions build/jsdoc/inline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
const inlineTag = require('jsdoc/lib/jsdoc/tag/inline')

exports.handlers = {
newDoclet ({doclet}) {
resolveDocletLinks(doclet, {base: doclet.longname})
},
}
exports.resolveDocletLinks = resolveDocletLinks
exports.resolveExternals = resolveExternalIdents
exports.resolveLinks = resolveLinks

function resolveDocletLinks (doclet, options = {}) {
const tags = options.tags || [
'description',
'see',
'typeExpression',
]

tags.forEach(tag => {
if (!doclet.hasOwnProperty(tag)) {
return
}

if (typeof doclet[tag] === 'string') {
doclet[tag] = resolveLinks(doclet[tag], options)
} else if (Array.isArray(doclet[tag])) {
doclet[tag].forEach((value, index, original) => {
let inner = {}

inner[tag] = value
resolveDocletLinks(inner, options)
original[index] = inner[tag]
})
} else if (doclet[tag]) {
resolveDocletLinks(doclet[tag], options)
}
})

return doclet
}

function resolveExternalIdents (string, options) {
return string.replace(/(ol\.[^\s])/.ig, '<a href="https://openlayers.org/en/latest/apidoc/$1.html">$1</a>')
}

function resolveLinks (string, options) {
let replacers = {
link: getLinkProcessor(options),
linkcode: getLinkProcessor(options),
}

return inlineTag.replaceInlineTags(string, replacers).newString
}

// copy-paste from jsdoc/lib/jsdoc/util/templateHelper
// a bit adopted for Vue
function getLinkProcessor (options) {
return function processLink (string, tagInfo) {
const leading = extractLeadingText(string, tagInfo.completeTag)
let linkText = leading.leadingText
let monospace
let split
let target

string = leading.string

split = splitLinkText(tagInfo.text)
target = split.target
linkText = linkText || split.linkText
monospace = useMonospace(tagInfo.tag, tagInfo.text)

return string.replace(tagInfo.completeTag, buildLink(target, linkText, Object.assign(options, {
monospace,
})))
}
}

function extractLeadingText (string, completeTag) {
const tagIndex = string.indexOf(completeTag)
let leadingText = null
const leadingTextRegExp = /\[(.+?)\]/g
let leadingTextInfo = leadingTextRegExp.exec(string)

// did we find leading text, and if so, does it immediately precede the tag?
while (leadingTextInfo && leadingTextInfo.length) {
if (leadingTextInfo.index + leadingTextInfo[0].length === tagIndex) {
string = string.replace(leadingTextInfo[0], '')
leadingText = leadingTextInfo[1]
break
}

leadingTextInfo = leadingTextRegExp.exec(string)
}

return {leadingText, string}
}

function buildLink (longname, linkText, options) {
let fileUrl, text
// handle cases like:
// @see <http://example.org>
// @see http://example.org
longname = longname ? longname.replace(/^<|>$/g, '') : ''
text = linkText || longname
text = options.monospace ? '<code>' + text + '</code>' : text

if (hasUrlPrefix(longname)) {
fileUrl = longname

return `<a href="${fileUrl}" target="_blank">${text}</a>`
}
// inner page link
if (longname.indexOf(options.base) === 0) {
let ident = longname.replace(/^module:/, '').replace('/', '-').toLowerCase()

return `<a @click="scrollTo('${ident}')">${text}</a>`
}
// link to another doc page
fileUrl = longname.replace(/^module:/, '').split('/')[0]

return `<router-link to="${fileUrl}">${text}</router-link>`
}

function useMonospace (tag, text) {
let result = false

if (tag === 'linkplain') {
result = false
} else if (tag === 'linkcode') {
result = true
}

return result || false
}

function hasUrlPrefix (text) {
return (/^(http|ftp)s?:\/\//).test(text)
}

function splitLinkText (text) {
let linkText
let target
let splitIndex

// if a pipe is not present, we split on the first space
splitIndex = text.indexOf('|')
if (splitIndex === -1) {
splitIndex = text.search(/\s/)
}

if (splitIndex !== -1) {
linkText = text.substr(splitIndex + 1)
// Normalize subsequent newlines to a single space.
linkText = linkText.replace(/\n+/, ' ')
target = text.substr(0, splitIndex)
}

return {
linkText,
target: target || text,
}
}
Loading

0 comments on commit b8d6457

Please sign in to comment.