Skip to content

feat(docs): Allow sub-components to show reference info for slots and events #2132

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

Merged
merged 108 commits into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
1f0d395
feat(docs): Allow sub-components to show documentation for slots and …
tmorehouse Nov 4, 2018
b32f27d
importAll: normalize meta.components to array of objects form
tmorehouse Nov 4, 2018
c18da0f
components/_slug.vue: no need to test if sub-component is string or a…
tmorehouse Nov 4, 2018
ea88f73
Update importdoc.vue
tmorehouse Nov 4, 2018
2313906
button/package.json
tmorehouse Nov 4, 2018
073eb1a
update breadcrumb/package.json
tmorehouse Nov 4, 2018
be5f251
Update button-close.js
tmorehouse Nov 4, 2018
b845bad
Update button-close.js
tmorehouse Nov 4, 2018
cfa60ea
Update carousel-slide.js
tmorehouse Nov 4, 2018
ded6c77
Update carousel-slide.js
tmorehouse Nov 4, 2018
72a2fc3
Update package.json
tmorehouse Nov 4, 2018
a4659b4
update dropdown/package.json
tmorehouse Nov 4, 2018
1367f18
lint
tmorehouse Nov 4, 2018
9dad134
add reference meta for form-select slot
tmorehouse Nov 4, 2018
f9e44da
update form-checkbox package.json
tmorehouse Nov 4, 2018
a0a7ae5
Update package.json
tmorehouse Nov 5, 2018
9bfeded
Update form-radio/package.json
tmorehouse Nov 5, 2018
f411f72
Update tabs/package.json
tmorehouse Nov 5, 2018
2abd88b
minor update to progress docs
tmorehouse Nov 5, 2018
a5b13b4
Update componentdoc.vue
tmorehouse Nov 5, 2018
2991e12
Update componentdoc.vue
tmorehouse Nov 5, 2018
8e04e68
Update button-group/package.json
tmorehouse Nov 5, 2018
97a872a
Update button-toolbar/package.json
tmorehouse Nov 5, 2018
29e506e
Update button/package.json
tmorehouse Nov 5, 2018
3e28896
Update dropdown/package.json
tmorehouse Nov 5, 2018
70a69fe
lint
tmorehouse Nov 5, 2018
b7a4df2
Update _slug.vue
tmorehouse Nov 5, 2018
1bd85bb
Update componentdoc.vue
tmorehouse Nov 5, 2018
f6225ec
Update form-checkbox/package.json
tmorehouse Nov 5, 2018
f419cf1
Update form-group/package.json
tmorehouse Nov 5, 2018
9e5f93f
Update form-file/package.json
tmorehouse Nov 5, 2018
fb65bc8
Update componentdoc.vue
tmorehouse Nov 5, 2018
12171e9
Update README.md
tmorehouse Nov 5, 2018
23ae1a6
Update README.md
tmorehouse Nov 5, 2018
eedae4d
Update README.md
tmorehouse Nov 5, 2018
2a57adf
Update README.md
tmorehouse Nov 5, 2018
b44b95c
Update README.md
tmorehouse Nov 5, 2018
3437758
Update README.md
tmorehouse Nov 5, 2018
e2c2aa0
Update README.md
tmorehouse Nov 5, 2018
9f3e6ca
Update form-input/package.json
tmorehouse Nov 5, 2018
34bd814
Update README.md
tmorehouse Nov 5, 2018
7ba1935
update form-radio/package.json
tmorehouse Nov 5, 2018
05bb39f
Update README.md
tmorehouse Nov 5, 2018
b3150d8
Update package.json
tmorehouse Nov 5, 2018
9cf241e
Update README.md
tmorehouse Nov 5, 2018
affa7e3
update form-textarea/package.json
tmorehouse Nov 5, 2018
08f52aa
Update README.md
tmorehouse Nov 5, 2018
71ec181
Update nav/package.json
tmorehouse Nov 5, 2018
7f92737
Update README.md
tmorehouse Nov 5, 2018
8ff085e
Update navbar-toggle.js
tmorehouse Nov 5, 2018
1ebe33c
Update README.md
tmorehouse Nov 5, 2018
d69502a
Update navbar/package.json
tmorehouse Nov 5, 2018
1b0fd85
componentdoc.vue: genrate IDs for section headings
tmorehouse Nov 5, 2018
1e1cb9d
Update toc.vue
tmorehouse Nov 5, 2018
3455f5f
Update docs-mixin.js
tmorehouse Nov 5, 2018
ab74b31
importdoc.vue: add heading ids
tmorehouse Nov 5, 2018
6a8c06a
Update _slug.vue
tmorehouse Nov 5, 2018
f91fbf4
docs/docs/utils/index.js auto generate component reference TOC
tmorehouse Nov 5, 2018
8bb0ce2
Update README.md
tmorehouse Nov 5, 2018
07344d1
Update index.js
tmorehouse Nov 5, 2018
91f8c7d
Update README.md
tmorehouse Nov 5, 2018
7db1680
Update README.md
tmorehouse Nov 5, 2018
ddb1f60
Update README.md
tmorehouse Nov 5, 2018
17c5afa
Update README.md
tmorehouse Nov 5, 2018
2b8ae5e
Update README.md
tmorehouse Nov 5, 2018
42b15d5
Update README.md
tmorehouse Nov 5, 2018
7520b74
Update README.md
tmorehouse Nov 5, 2018
b2ac847
Update README.md
tmorehouse Nov 5, 2018
929c45f
Update navbar-toggle.js
tmorehouse Nov 5, 2018
2fb8c91
Update README.md
tmorehouse Nov 5, 2018
6ca02ae
Update README.md
tmorehouse Nov 5, 2018
42b077e
Update README.md
tmorehouse Nov 5, 2018
73be917
Update README.md
tmorehouse Nov 5, 2018
cbf8b15
Update README.md
tmorehouse Nov 5, 2018
dfbff92
Update README.md
tmorehouse Nov 5, 2018
307be5c
Update README.md
tmorehouse Nov 5, 2018
1a76d5d
Update README.md
tmorehouse Nov 5, 2018
4156087
Update README.md
tmorehouse Nov 5, 2018
06069e3
Update README.md
tmorehouse Nov 5, 2018
359b1cc
Update README.md
tmorehouse Nov 5, 2018
5b62dfa
Update README.md
tmorehouse Nov 5, 2018
df1021c
Update README.md
tmorehouse Nov 5, 2018
ca38d0d
Update README.md
tmorehouse Nov 5, 2018
7d3d675
Update README.md
tmorehouse Nov 5, 2018
50cb410
Update README.md
tmorehouse Nov 5, 2018
93ae2d6
Update README.md
tmorehouse Nov 5, 2018
271a3b8
Update README.md
tmorehouse Nov 5, 2018
b3c2990
Update README.md
tmorehouse Nov 5, 2018
c9c8bdb
Update README.md
tmorehouse Nov 5, 2018
4e2eefe
Update README.md
tmorehouse Nov 5, 2018
91f06e9
Update README.md
tmorehouse Nov 5, 2018
adb60e2
Update README.md
tmorehouse Nov 5, 2018
caf650d
Update README.md
tmorehouse Nov 5, 2018
bfe9485
Update README.md
tmorehouse Nov 5, 2018
9bd135c
Update README.md
tmorehouse Nov 5, 2018
477c913
Update README.md
tmorehouse Nov 5, 2018
c080e80
Update componentdoc.vue
tmorehouse Nov 5, 2018
412aee8
Update componentdoc.vue
tmorehouse Nov 5, 2018
bf37aa4
Update _slug.vue
tmorehouse Nov 5, 2018
af1f2f6
Update _slug.vue
tmorehouse Nov 5, 2018
e6f9f90
Update search.vue
tmorehouse Nov 5, 2018
f53ef44
Update index.js
tmorehouse Nov 5, 2018
9dc0cc9
Update _slug.vue
tmorehouse Nov 5, 2018
2616d1f
Update README.md
tmorehouse Nov 5, 2018
11ea037
Update README.md
tmorehouse Nov 5, 2018
317fccd
Update README.md
tmorehouse Nov 5, 2018
83b9299
Update _slug.vue
tmorehouse Nov 5, 2018
8e43dff
Update _slug.vue
tmorehouse Nov 5, 2018
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
23 changes: 19 additions & 4 deletions docs/components/componentdoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<b-row
tag="header"
align-v="center">
<b-col sm="9"><h2><code>{{ tag }}</code></h2></b-col>
<b-col sm="9"><h2 :id="`comp-ref-${componentName}`"><code>{{ tag }}</code></h2></b-col>
<b-col
sm="3"
class="text-sm-right">
Expand All @@ -18,8 +18,16 @@
</b-col>
</b-row>

<article v-if="aliases && aliases.length > 0">
<h4 :id="`comp-ref-${componentName}-aliases`">Component aliases</h4>
<p><code>{{ tag }}</code> can also be used via the following aliases:</p>
<ul>
<li v-for="alias in aliases" :key="alias"><code>&lt;{{ kebabCase(alias) }}&gt;</code></li>
</ul>
</article>

<article v-if="props_items && props_items.length > 0">
<h4>Properties</h4>
<h4 :id="`comp-ref-${componentName}-props`">Properties</h4>
<b-table
:items="props_items"
:fields="props_fields"
Expand All @@ -35,7 +43,7 @@
</article>

<article v-if="slots && slots.length > 0">
<h4>Slots</h4>
<h4 :id="`comp-ref-${componentName}-slots`">Slots</h4>
<b-table
:items="slots"
:fields="slots_fields"
Expand All @@ -45,7 +53,7 @@
</article>

<article v-if="events && events.length > 0">
<h4>Events</h4>
<h4 :id="`comp-ref-${componentName}-events`">Events</h4>
<b-table
:items="events"
:fields="events_fields"
Expand Down Expand Up @@ -88,8 +96,15 @@ export default {
events: {
type: Array,
default: () => []
},
aliases: {
type: Array,
default: () => []
}
},
methods: {
kebabCase
},
computed: {
componentOptions () {
const component = Vue.options.components[this.component]
Expand Down
14 changes: 10 additions & 4 deletions docs/components/importdoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
v-if="components.length > 0 || directives.length > 0">

<article v-if="components.length > 0">
<h3>Importing Individual Components</h3>
<h3 id="importing-individual-components">Importing Individual {{ pluginTitle }} Components</h3>
<b-table
:items="componentImports"
small
Expand Down Expand Up @@ -32,7 +32,7 @@
</article>

<article v-if="directives.length > 0">
<h3>Importing Individual Directives</h3>
<h3 id="importing-individual-directives">Importing Individual {{ pluginTitle }} Directives</h3>
<b-table
:items="directiveImports"
small
Expand Down Expand Up @@ -62,7 +62,7 @@
</article>

<article class="pb-5">
<h3>Importing {{ pluginTitle }} as a Vue plugin</h3>
<h3 id="importing-as-a-plugin">Importing {{ pluginTitle }} as a Vue plugin</h3>
<p v-if="$route.name === 'docs-components-slug'">
This plugin includes all of the above listed individual
components<span v-if="directives.length"> and directives</span>.
Expand Down Expand Up @@ -105,6 +105,7 @@
<script>
import kebabCase from 'lodash/kebabCase'
import startCase from 'lodash/startCase'

export default {
props: {
meta: {}
Expand Down Expand Up @@ -133,7 +134,12 @@ export default {
})
},
components () {
return [].concat(this.meta.component, this.meta.components).filter(c => c)
let subcomponents = []
if (this.meta.components) {
// We just want the sub-component name
subcomponents = this.meta.components.map(m => m.component)
}
return [].concat(this.meta.component, subcomponents).filter(c => c)
},
directives () {
return [].concat(this.meta.directive, this.meta.directives).filter(d => d)
Expand Down
10 changes: 5 additions & 5 deletions docs/components/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,26 @@ function process(readme, section, page) {
}

// Async build the search database
import('~/markdown/intro/README.md').then(readme => {
import('~/markdown/intro/README.md' /* webpackChunkName: "docs/intro" */).then(readme => {
process(readme.default, '', '');
});
Object.keys(_components).forEach(page => {
import('~/../src/components/' + page + '/README.md').then(readme => {
import('~/../src/components/' + page + '/README.md' /* webpackChunkName: "docs/components" */).then(readme => {
process(readme.default, 'components', page);
});
});
Object.keys(_directives).forEach(page => {
import('~/../src/directives/' + page + '/README.md').then(readme => {
import('~/../src/directives/' + page + '/README.md' /* webpackChunkName: "docs/directives" */).then(readme => {
process(readme.default, 'directives', page);
});
});
Object.keys(_reference).forEach(page => {
import('~/markdown/reference/' + page + '/README.md').then(readme => {
import('~/markdown/reference/' + page + '/README.md' /* webpackChunkName: "docs/reference" */).then(readme => {
process(readme.default, 'reference', page);
});
});
Object.keys(_misc).forEach(page => {
import('~/markdown/misc/' + page + '/README.md').then(readme => {
import('~/markdown/misc/' + page + '/README.md' /* webpackChunkName: "docs/misc" */).then(readme => {
process(readme.default, 'misc', page);
});
});
Expand Down
8 changes: 5 additions & 3 deletions docs/components/toc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,19 @@ import { scrollTo, offsetTop, makeTOC } from '~/utils'
export default {
data () {
return {
readme: ''
readme: '',
meta: null
}
},
computed: {
toc () {
return makeTOC(this.readme)
return makeTOC(this.readme, this.meta)
}
},
mounted () {
this.$root.$on('setTOC', readme => {
this.$root.$on('setTOC', (readme, meta) => {
this.readme = readme
this.meta = meta || null
})
},
methods: {
Expand Down
54 changes: 31 additions & 23 deletions docs/pages/docs/components/_slug.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
<template>
<div class="container">
<div class="bd-content" v-html="readme" v-play></div>

<componentdoc :component="meta.component" :events="meta.events" :slots="meta.slots"></componentdoc>

<b-card class="my-4">
<small class="font-italic">
Trying to get native browser events working on your component? Use the
<code>.native</code>
modifier to capture browser native events such as:
<code>@click.native="..."</code>,
<code>@mouseover.native="..."</code>, etc. See the the official
<a href="https://vuejs.org/v2/guide/components.html#Binding-Native-Events-to-Components">Vue.js documentation</a>
for more information.
</small>
</b-card>

<componentdoc :component="component" :key="component" v-for="component in meta.components"></componentdoc>

<importdoc :meta="meta"></importdoc>
</div>
<main class="container">
<div class="bd-content" v-html="readme" v-play></div>

<section class="bd-content">
<h2 id="component-reference">{{ startCase(meta.title)}} Component Reference</h2>

<!-- main component reference information -->
<componentdoc :component="meta.component"
:events="meta.events"
:slots="meta.slots"
:aliases="meta.aliases">
</componentdoc>

<!-- sub-component reference information -->
<componentdoc v-for="meta in meta.components"
:key="meta.component"
:component="meta.component"
:events="meta.events"
:slots="meta.slots"
:aliases="meta.aliases">
</componentdoc>

<!-- Component importing information -->
<importdoc :meta="meta"></importdoc>
</section>

</main>
</template>


Expand All @@ -28,18 +34,20 @@ import componentdoc from "~/components/componentdoc.vue";
import importdoc from "~/components/importdoc.vue";
import { components as _meta } from "~/content";
import docsMixin from "~/plugins/docs-mixin";
import startCase from 'lodash/startCase'

const getReadMe = name => import('~/../src/components/' + name + '/README.md' /* webpackChunkName: "docs/components" */)

export default {
components: { componentdoc, importdoc },
mixins: [docsMixin],
layout: "docs",

methods: {
startCase
},
validate({ params }) {
return Boolean(_meta[params.slug])
},

async asyncData({ params }) {
const readme = await getReadMe(params.slug)
const meta = _meta[params.slug]
Expand Down
37 changes: 21 additions & 16 deletions docs/pages/docs/directives/_slug.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
<template>
<div class="container">
<div class="bd-content" v-html="readme" v-play></div>

<importdoc :meta="meta"></importdoc>
</div>
<main class="container">
<div class="bd-content" v-html="readme" v-play></div>
<section class="bd-content">
<h2 id="directive-reference">{{ metaTitle }} Directive Reference</h2>
<importdoc :meta="meta"></importdoc>
</section>
</main>
</template>

<script>
import importdoc from '~/components/importdoc.vue';
import { directives as _meta } from "~/content";
import docsMixin from "~/plugins/docs-mixin";
import startCase from 'lodash/startCase'

const getReadMe = name => import('~/../src/directives/' + name + '/README.md' /* webpackChunkName: "docs/directives" */)

export default {
mixins: [docsMixin],
components: { importdoc },
computed: {
metaTitle () {
return startCase(this.meta.title)
}
},
layout: "docs",

validate({ params }) {
return Boolean(_meta[params.slug])
return Boolean(_meta[params.slug])
},

async asyncData({ params }) {
const readme = await getReadMe(params.slug)
const meta = _meta[params.slug]

return {
readme: readme.default,
meta
}
const readme = await getReadMe(params.slug)
const meta = _meta[params.slug]
return {
readme: readme.default,
meta
}
}
};
}
</script>
2 changes: 1 addition & 1 deletion docs/plugins/docs-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {
clearTimeout(this.scrollTimeout)
this.scrollTimeout = null
this.focusScroll()
this.$root.$emit('setTOC', this.readme)
this.$root.$emit('setTOC', this.readme, this.meta || null)
},

updated () {
Expand Down
Loading