Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6fc3139
collapse module names per config
davidsulc Oct 18, 2018
033ccec
display collapsed prefixes in sidebar
davidsulc Oct 18, 2018
febc7d1
ran mix build
davidsulc Oct 18, 2018
aaa5f49
documented the collapse_nested_module_names option
davidsulc Oct 18, 2018
45bc111
replaced pipe with function call
davidsulc Oct 18, 2018
50d8fee
provide context for collapsed module names
davidsulc Oct 20, 2018
3fbbca8
refactored empty node handling in sidebar
davidsulc Oct 20, 2018
4397d19
diplay context module in sidebar as non-clickable element
davidsulc Oct 20, 2018
b98c920
context modules must be inserted in each type separately
davidsulc Oct 20, 2018
a9aa6e6
handle collapsing when clicking on prefix
davidsulc Oct 21, 2018
43b7116
only display an indication of shortening, not the prefix itself
davidsulc Oct 21, 2018
6df86bd
ran formatter
davidsulc Oct 21, 2018
4af999f
display nested modules beneath prefix
davidsulc Oct 21, 2018
648a2ef
removed group_modules_by_nesting artifact
davidsulc Oct 23, 2018
e126525
removed dead code
davidsulc Oct 23, 2018
d0f4dd6
streamlined sidebar styling
davidsulc Oct 23, 2018
990d7c4
renamed title_truncated to nested_title
davidsulc Oct 23, 2018
4d19b91
add context nodes in UI
davidsulc Oct 23, 2018
b124154
used iodata to build JSONed sidebar items
davidsulc Oct 24, 2018
eb4fa8e
added test for :group_modules_by_nesting
davidsulc Oct 24, 2018
ff459ac
added fixtures
davidsulc Oct 24, 2018
d373d59
rename block helpers for consistency
davidsulc Oct 25, 2018
a3a1cf4
add module nesting information in the retriever
davidsulc Oct 25, 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
10 changes: 6 additions & 4 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import markdown from 'highlight.js/lib/languages/markdown'
import sql from 'highlight.js/lib/languages/sql'
import xml from 'highlight.js/lib/languages/xml'

import hasContent from './template-helpers/hasContent'
import isArray from './template-helpers/isArray'
import isEmptyNode from './template-helpers/isEmptyNode'
import isLocal from './template-helpers/isLocal'
import newGroup from './template-helpers/newGroup'
import groupChanged from './template-helpers/groupChanged'
import nestingChanged from './template-helpers/nestingChanged'
import showSummary from './template-helpers/showSummary'

import {initialize as initEvents} from './events'
Expand All @@ -32,10 +33,11 @@ window.$ = $

$(() => {
// Set up Handlebars.js
Handlebars.registerHelper('hasContent', hasContent)
Handlebars.registerHelper('isArray', isArray)
Handlebars.registerHelper('isEmptyNode', isEmptyNode)
Handlebars.registerHelper('isLocal', isLocal)
Handlebars.registerHelper('newGroup', newGroup)
Handlebars.registerHelper('groupChanged', groupChanged)
Handlebars.registerHelper('nestingChanged', nestingChanged)
Handlebars.registerHelper('showSummary', showSummary)

// Set up Highlight.js
Expand Down
4 changes: 3 additions & 1 deletion assets/js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ function fillSidebarWithNodes (nodes, filter) {

$('#full-list li a').on('click', e => {
var $target = $(e.target)
if ($target.hasClass('expand')) {
// the user might have clicked on the nesting indicator
var linkTag = $target.is('a') ? $target : $target.closest('a')
if (linkTag.hasClass('expand')) {
e.preventDefault()
$(e.target).closest('li').toggleClass('open')
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default function (context, nodeGroup, options) {
var group = nodeGroup || ''
if (context.group !== group) {
// reset the nesting context for the #nestingChanged block helper
delete context.nestedContext
context.group = group
return options.fn(this)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
export default function (node, options) {
if (hasItems(node.headers)) {
return options.inverse(this)
return options.fn(this)
}

if (node.nodeGroups) {
for (let {nodes} of node.nodeGroups) {
if (hasItems(nodes)) {
return options.inverse(this)
return options.fn(this)
}
}
}

return options.fn(this)
return options.inverse(this)
}

function hasItems (items) {
Expand Down
9 changes: 9 additions & 0 deletions assets/js/template-helpers/nestingChanged.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function (context, nestedContext, options) {
// context.nestedContext is also reset each time a new group
// is encountered (the value is reset within the #groupChanged
// block helper)
if (context.nestedContext !== nestedContext) {
context.nestedContext = nestedContext
return options.fn(this)
}
}
96 changes: 52 additions & 44 deletions assets/js/templates/sidebar-items.handlebars
Original file line number Diff line number Diff line change
@@ -1,50 +1,58 @@
<ul id="full-list">
{{#each nodes as |node nodeId|}}
{{#newGroup ../this node.group}}
{{#each nodes as |node nodeId|}}
{{#groupChanged ../this node.group}}
<li class="group">{{node.group}}</li>
{{/newGroup}}
<li class="{{#isLocal node.id}}clicked open{{/isLocal}}">
{{/groupChanged}}

{{!-- When visiting a module page, the link to this module page
in the menu should not link to a new page, instead should link
to the top of the page itself. --}}
{{#isEmptyNode node}}
<a href="{{node.id}}.html" title="{{node.title}}">{{node.title}}</a>
{{else}}
<a href="{{node.id}}.html" title="{{node.title}}" class="expand">{{node.title}}</a>
{{#nestingChanged ../this node.nested_context}}
<li class="nesting-context" title="{{node.nested_context}}" aria-hidden="true">{{node.nested_context}}</li>
{{/nestingChanged}}

<ul>
<li>
<a href="{{node.id}}.html#content">Top</a>
</li>

{{#isArray node.headers}}
{{#each node.headers}}
<li>
<a href="{{node.id}}.html#{{{anchor}}}">{{id}}</a>
</li>
{{/each}}
<li class="{{#isLocal node.id}}clicked open{{/isLocal}} {{#if node.nested_title}}nested{{/if}}">
{{! When visiting a module page, the link to this module page
in the menu should not link to a new page, instead should link
to the top of the page itself. }}
<a href="{{node.id}}.html" title="{{node.title}}" {{#hasContent node}}class="expand"{{/hasContent}}>
{{#if node.nested_title}}
{{node.nested_title}}
{{else}}
{{#showSummary node}}
<li>
<a href="{{node.id}}.html#summary">Summary</a>
</li>
{{/showSummary}}
{{#each node.nodeGroups as |group|}}
<li class="docs">
<a href="{{node.id}}.html#{{group.key}}" class="expand">{{group.name}}</a>
<ul class="{{group.key}}-list deflist">
{{#each group.nodes}}
<li>
<a href="{{node.id}}.html#{{anchor}}">{{id}}</a>
</li>
{{/each}}
</ul>
</li>
{{/each}}
{{/isArray}}
</ul>
{{/isEmptyNode}}
</li>
{{/each}}
{{node.title}}
{{/if}}
</a>

{{#hasContent node}}
<ul>
<li>
<a href="{{node.id}}.html#content">Top</a>
</li>

{{#isArray node.headers}}
{{#each node.headers}}
<li>
<a href="{{node.id}}.html#{{{anchor}}}">{{id}}</a>
</li>
{{/each}}
{{else}}
{{#showSummary node}}
<li>
<a href="{{node.id}}.html#summary">Summary</a>
</li>
{{/showSummary}}
{{#each node.nodeGroups as |group|}}
<li class="docs">
<a href="{{node.id}}.html#{{group.key}}" class="expand">{{group.name}}</a>
<ul class="{{group.key}}-list deflist">
{{#each group.nodes}}
<li>
<a href="{{node.id}}.html#{{anchor}}">{{id}}</a>
</li>
{{/each}}
</ul>
</li>
{{/each}}
{{/isArray}}
</ul>
{{/hasContent}}
</li>
{{/each}}
</ul>
8 changes: 8 additions & 0 deletions assets/less/sidebar.less
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@
&.open > ul {
display: block;
}

&.nesting-context {
opacity: 0.6;
}

&.nested {
margin-left: 2ex;
}
}

li.group {
Expand Down

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

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions formatters/html/dist/html-2c36aea493b65986bbc5.css

Large diffs are not rendered by default.

Loading