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

Create documentation site with vuepress (#1454) #2051

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
.nyc_output
coverage
bench/.results
docs/.vuepress/dist
51 changes: 51 additions & 0 deletions docs/.vuepress/components/VersionSelector.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
<div class="nav-item">
<DropdownLink :item="{
text: 'Versions',
items: tags,
type: 'links'
}"/>
</div>
</template>

<script>
import ky from "ky";
import DropdownLink from "../theme/DropdownLink.vue";
import { resolveNavLinkItem } from "../theme/util";
import NavLink from "../theme/NavLink.vue";

export default {
name: "VersionSelector",
data() {
return {
tags: [],
location:
typeof window !== "undefined" && window !== null
? window.location.origin
: ""
};
},
components: {
DropdownLink,
NavLink
},
mounted() {
if (typeof window !== "undefined" && window !== null) {
ky.get(`${window.location.origin}/releases.json`).then(response => {
response.json().then(releases => {
releases.tags.forEach(tag => {
this.tags.push({
text: tag.name,
type: "link",
link: `${window.location.origin}/${tag.name}`
});
});
});
});
}
}
};
</script>

<style>
</style>
99 changes: 99 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
module.exports = {
title: 'AVA JS',
description: 'Futuristic test runner',
head: [['link', { rel: 'icon', href: '/logo.png' }]],
themeConfig: {
repo: 'avajs/ava',
docsDir: 'docs',
nav: [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/' },
{ text: 'Recipes', link: '/recipes/' },
{
text: 'Related',
items: [
{
text: 'Eslint Plugin',
link: 'https://github.com/avajs/eslint-plugin-ava'
},
{
text: 'Sublime Plugin',
link: 'https://github.com/avajs/sublime-ava'
},
{
text: 'VS Code Plugin',
link: 'https://github.com/samverschueren/vscode-ava'
},
{
text: 'Gulp Plugin',
link: 'https://github.com/avajs/gulp-ava'
},
{
text: 'Grunt Plugin',
link: 'https://github.com/avajs/grunt-ava'
},
{
text: 'More',
link: 'https://github.com/avajs/awesome-ava#packages'
}
]
},
{
text: 'Links',
items: [
{
text: 'AVA stickers, t-shirts, etc',
link:
'https://www.redbubble.com/people/sindresorhus/works/30330590-ava-logo'
},
{
text: 'Awesome list',
link: 'https://github.com/avajs/awesome-ava'
},
{
text: 'AVA Casts',
link: 'http://avacasts.com'
}
]
}
],
sidebar: {
'/guide/': [
'',
'01-writing-tests',
'02-execution-context',
'03-assertions',
'04-snapshot-testing.md',
'05-command-line',
'06-configuration',
'07-test-timeouts',
'08-common-pitfalls'
],
'/recipes/': [
'',
'babel',
'babelrc',
'browser-testing',
'code-coverage',
'debugging-with-chrome-devtools',
'debugging-with-vscode',
'debugging-with-webstorm',
'endpoint-testing-with-mongoose',
'endpoint-testing',
'es-modules',
'flow',
'isolated-mongodb-integration-tests',
'jspm-systemjs',
'passing-arguments-to-your-test-files',
'puppeteer',
'react',
'test-setup',
'typescript',
'vue',
'watch-mode',
'when-to-use-plan'
]
},
editLinks: true
}
}
Binary file added docs/.vuepress/public/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.vuepress/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/.vuepress/public/releases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "tags": [{ "name": "v1.0.0" }, { "name": "v0.1.2" }] }
156 changes: 156 additions & 0 deletions docs/.vuepress/theme/AlgoliaSearchBox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<template>
<form
id="search-form"
class="algolia-search-wrapper search-box"
>
<input
id="algolia-search-input"
class="search-query"
>
</form>
</template>

<script>
export default {
props: ['options'],

mounted () {
this.initialize(this.options, this.$lang)
},

methods: {
initialize (userOptions, lang) {
Promise.all([
import(/* webpackChunkName: "docsearch" */ 'docsearch.js/dist/cdn/docsearch.min.js'),
import(/* webpackChunkName: "docsearch" */ 'docsearch.js/dist/cdn/docsearch.min.css')
]).then(([docsearch]) => {
docsearch = docsearch.default
const { algoliaOptions = {}} = userOptions
docsearch(Object.assign(
{},
userOptions,
{
inputSelector: '#algolia-search-input',
// #697 Make docsearch work well at i18n mode.
algoliaOptions: Object.assign({
'facetFilters': [`lang:${lang}`].concat(algoliaOptions.facetFilters || [])
}, algoliaOptions)
}
))
})
},

update (options, lang) {
this.$el.innerHTML = '<input id="algolia-search-input" class="search-query">'
this.initialize(options, lang)
}
},

watch: {
$lang (newValue) {
this.update(this.options, newValue)
},

options (newValue) {
this.update(newValue, this.$lang)
}
}
}
</script>

<style lang="stylus">
@import './styles/config.styl'

.algolia-search-wrapper
& > span
vertical-align middle
.algolia-autocomplete
line-height normal
.ds-dropdown-menu
background-color #fff
border 1px solid #999
border-radius 4px
font-size 16px
margin 6px 0 0
padding 4px
text-align left
&:before
border-color #999
[class*=ds-dataset-]
border none
padding 0
.ds-suggestions
margin-top 0
.ds-suggestion
border-bottom 1px solid $borderColor
.algolia-docsearch-suggestion--highlight
color #2c815b
.algolia-docsearch-suggestion
border-color $borderColor
padding 0
.algolia-docsearch-suggestion--category-header
padding 5px 10px
margin-top 0
background $accentColor
color #fff
font-weight 600
.algolia-docsearch-suggestion--highlight
background rgba(255, 255, 255, 0.6)
.algolia-docsearch-suggestion--wrapper
padding 0
.algolia-docsearch-suggestion--title
font-weight 600
margin-bottom 0
color $textColor
.algolia-docsearch-suggestion--subcategory-column
vertical-align top
padding 5px 7px 5px 5px
border-color $borderColor
background #f1f3f5
&:after
display none
.algolia-docsearch-suggestion--subcategory-column-text
color #555
.algolia-docsearch-footer
border-color $borderColor
.ds-cursor .algolia-docsearch-suggestion--content
background-color #e7edf3 !important
color $textColor

@media (min-width: $MQMobile)
.algolia-search-wrapper
.algolia-autocomplete
.algolia-docsearch-suggestion
.algolia-docsearch-suggestion--subcategory-column
float none
width 150px
min-width 150px
display table-cell
.algolia-docsearch-suggestion--content
float none
display table-cell
width 100%
vertical-align top
.ds-dropdown-menu
min-width 515px !important

@media (max-width: $MQMobile)
.algolia-search-wrapper
.ds-dropdown-menu
min-width calc(100vw - 4rem) !important
max-width calc(100vw - 4rem) !important
.algolia-docsearch-suggestion--wrapper
padding 5px 7px 5px 5px !important
.algolia-docsearch-suggestion--subcategory-column
padding 0 !important
background white !important
.algolia-docsearch-suggestion--subcategory-column-text:after
content " > "
font-size 10px
line-height 14.4px
display inline-block
width 5px
margin -3px 3px 0
vertical-align middle

</style>
Loading