Skip to content

Commit

Permalink
✨ Add documentation badge
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck committed Jun 8, 2019
1 parent d2ee432 commit dd435ca
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const {
askContributing,
askProjectVersion,
askProjectPrerequisites,
askLicenseName
askLicenseName,
askProjectDocumentationUrl
} = require('./questions')

/**
Expand All @@ -29,6 +30,7 @@ const askQuestions = async () => {
askProjectName,
askProjectVersion,
askProjectDescription,
askProjectDocumentationUrl,
askAuhtorName,
askAuthorGithub,
askAuthorTwitter,
Expand Down
4 changes: 3 additions & 1 deletion src/questions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const askLicenseUrl = require('./license-url')
const askContributing = require('./contributing')
const askProjectVersion = require('./project-version')
const askProjectPrerequisites = require('./project-prerequisites')
const askProjectDocumentationUrl = require('./project-documentation-url')

module.exports = {
askProjectName,
Expand All @@ -19,5 +20,6 @@ module.exports = {
askLicenseUrl,
askContributing,
askProjectVersion,
askProjectPrerequisites
askProjectPrerequisites,
askProjectDocumentationUrl
}
6 changes: 6 additions & 0 deletions src/questions/project-documentation-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = projectInfos => ({
type: 'input',
message: '📘 Project documenration url (use empty value to skip)',
name: 'projectDocumentationUrl',
default: projectInfos.documentationUrl
})
4 changes: 3 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const getProjectInfos = async () => {
const author = get(packageJson, 'author', undefined)
const version = get(packageJson, 'version', undefined)
const licenseName = get(packageJson, 'license', undefined)
const documentationUrl = get(packageJson, 'homepage', undefined)
const repositoryUrl = await getReposUrl(packageJson)
const contributingUrl = await getReposIssuesUrl(packageJson)
const githubUsername = isGithubRepository(repositoryUrl)
Expand All @@ -145,7 +146,8 @@ const getProjectInfos = async () => {
githubUsername,
engines,
licenseName,
licenseUrl
licenseUrl,
documentationUrl
}
}

Expand Down
5 changes: 5 additions & 0 deletions templates/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<% if (projectVersion) { -%>
<img src="https://img.shields.io/badge/version-<%= projectVersion %>-blue.svg?cacheSeconds=2592000" />
<% } -%>
<% if (projectDocumentationUrl) { -%>
<a href="<%= projectDocumentationUrl %>">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" target="_blank" />
</a>
<% } -%>
<% if (licenseName && licenseUrl) { -%>
<a href="<%= licenseUrl %>">
<img alt="License: <%= licenseName %>" src="https://img.shields.io/badge/License-<%= licenseName %>-yellow.svg" target="_blank" />
Expand Down

0 comments on commit dd435ca

Please sign in to comment.