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

Fix generate docs links #494

Merged
Merged
Changes from all 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
11 changes: 7 additions & 4 deletions scripts/generate-rule-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,23 +191,26 @@ function linkToVersion(version) {
}

function linkToSource(rule) {
const link = rule.file.replace(path.resolve(path.join(__dirname, '..')), '')
const link = localPathToUri(rule.file)
return `https://github.com/protofire/solhint/tree/master${link}`
}

function linkToDocumentSource(rule) {
const link = rule.file
.replace(path.resolve(path.join(__dirname, '..')), '')
const link = localPathToUri(rule.file)
.replace('lib/rules', 'docs/rules')
.replace(/\.js$/, '.md')
return `https://github.com/protofire/solhint/tree/master${link}`
}

function linkToTestCase(rule) {
const link = rule.file.replace(path.resolve(path.join(__dirname, '..', 'lib', 'rules')), '')
const link = localPathToUri(rule.file).replace('lib/rules/', '')
return `https://github.com/protofire/solhint/tree/master/test/rules${link}`
}

function localPathToUri(file) {
return file.replace(path.resolve(path.join(__dirname, '..')), '').split(path.sep).join('/')
}

function loadExamples(rule) {
if (!rule.meta.docs.examples) {
return 'This rule does not have examples.'
Expand Down
Loading