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

Added an option to strip path prefixes #385

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions docco.js

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

9 changes: 7 additions & 2 deletions docco.litcoffee
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ and rendering it to the specified output path.
write = (source, sections, config) ->

destination = (file) ->
path.join(config.output, path.dirname(file), path.basename(file, path.extname(file)) + '.html')
path.join(config.output, path.dirname(file).replace(config.prefix, ''), path.basename(file, path.extname(file)) + '.html')

relative = (file) ->
to = path.dirname(path.resolve(file))
Expand All @@ -216,9 +216,10 @@ name of the source file.
hasTitle = first and first.type is 'heading' and first.depth is 1
title = if hasTitle then first.text else path.basename source
css = relative path.join(config.output, path.basename(config.css))
prefix = config.prefix

html = config.template {sources: config.sources, css,
title, hasTitle, sections, path, destination, relative}
title, hasTitle, sections, path, destination, relative, prefix}

console.log "docco: #{source} -> #{destination source}"
fs.outputFileSync destination(source), html
Expand All @@ -233,6 +234,7 @@ user-specified options.
defaults =
layout: 'parallel'
output: 'docs'
prefix: ''
template: null
css: null
extension: null
Expand All @@ -248,6 +250,8 @@ source files for languages for which we have definitions.

config.languages = buildMatchers config.languages

config.prefix = new RegExp "^#{config.prefix}(\/?)"

The user is able to override the layout file used with the `--template` parameter.
In this case, it is also neccessary to explicitly specify a stylesheet file.
These custom templates are compiled exactly like the predefined ones, but the `public` folder
Expand Down Expand Up @@ -341,6 +345,7 @@ Parse options using [Commander](https://github.com/visionmedia/commander.js).
.option('-L, --languages [file]', 'use a custom languages.json', _.compose JSON.parse, fs.readFileSync)
.option('-l, --layout [name]', 'choose a layout (parallel, linear or classic)', c.layout)
.option('-o, --output [path]', 'output to a given folder', c.output)
.option('-p, --prefix [path]', 'trim file prefix', c.prefix)
.option('-c, --css [file]', 'use a custom css file', c.css)
.option('-t, --template [file]', 'use a custom .jst template', c.template)
.option('-e, --extension [ext]', 'assume a file extension for all inputs', c.extension)
Expand Down
2 changes: 1 addition & 1 deletion resources/parallel/docco.jst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<% for (var i=0, l=sources.length; i<l; i++) { %>
<% var source = sources[i]; %>
<a class="source" href="<%= relative(destination(source)) %>">
<%= source %>
<%= source.replace(prefix, '') %>
</a>
<% } %>
</div>
Expand Down