Commit c83263df authored by Hendrik van Antwerpen's avatar Hendrik van Antwerpen

Add documentation and another test case.

parent ce54dcfe
......@@ -86,6 +86,33 @@ are embedded in the Bibtex fields. This option provides a way to circumvent
the problem that the double braces functionality of BibTex is accidentally
parsed by Liquid, while it was intended to keep the exact capitalization style.
The `sort_by` and `order` options specify if and how bibliography
entries are sorted. Entries can be sorted on multiple fields, by using
a list of keys, e.g. `sort_by: year,month`. Ordering can be specified
per sort level, e.g. `order: descending,ascending` will sort the years
descending, but per year the months are ascending. If there are more
sort keys than order directives, the last order entry is used for the
remaining keys.
The `group_by` and `group_order` options specify how bibliography
items are grouped. Grouping can be multi-level as well,
e.g. `group_by: type, year` groups entries per publication type, and
within those groups per year. Ordering for groups is specified in the
same way as the sort order. Publication types -- specified with group
key `type`, can be ordered by adding `type_order` to the
configuration. For example, `type_order: article,techreport` lists
journal articles before technical reports. Types not mentioned in
`type_order` are considered smaller than types that are
mentioned. Types can be merge in one group using the `type_aliases`
setting. By default `phdthesis` and `mastersthesis` are grouped as
`thesis`. By using, for example, `type_aliases: { inproceeding =>
article}`, journal and conference articles appear in a single
group. The display names for entry types are specified with
`type_names`. Names for common types are provided, but they can be
extended or overridden. For example, the default name for `article` is
*Journal Articles*, but it can be changed to *Papers* using
`type_name: { article => 'Papers' }`.
### Bibliographies
Once you have loaded Jekyll-Scholar, all files with the extension `.bib` or
......
......@@ -239,6 +239,34 @@ Feature: Grouping BibTeX Bibliographies
And I should not see "Journal Articles" in "_site/scholar.html"
And I should see "Books" in "_site/scholar.html"
@tags @grouping
Scenario: Type Aliases
Given I have a scholar configuration with:
| key | value |
| group_by | type |
| type_aliases | { phdthesis: phdthesis } |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
@mastersthesis{ruby1,
title = {MSc Thesis},
}
@phdthesis{ruby2,
title = {PhD Thesis},
}
"""
And I have a page "scholar.html":
"""
---
---
{% bibliography -f references %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
Then I should see "PhD Theses" in "_site/scholar.html"
And I should not see "Master's Theses" in "_site/scholar.html"
@tags @grouping
Scenario: Month Names
Given I have a scholar configuration with:
......
......@@ -44,6 +44,8 @@ module Jekyll
'incollection' => 'Book Chapters',
'inproceedings' => 'Conference Articles',
'thesis' => 'Theses',
'mastersthesis' => 'Master\'s Theses',
'phdthesis' => 'PhD Theses',
'manual' => 'Manuals',
'techreport' => 'Technical Reports',
'misc' => 'Miscellaneous',
......
......@@ -61,11 +61,10 @@ module Jekyll
else
groupsOrItems
.map do |keyvalue,value|
bibhead = content_tag(tags.first,
bibhead = content_tag(tags.first || group_tags.last,
group_name(keys.first, keyvalue),
:class => config['bibliography_class'])
bibentries = group_renderer(value, keys.drop(1),
tags.length > 1 ? tags.drop(1) : tags)
bibentries = group_renderer(value, keys.drop(1), tags.drop(1))
bibhead + "\n" + bibentries
end
.join("\n")
......
......@@ -202,7 +202,7 @@ module Jekyll
group_value(keys.first,item)
end
.sort do |e1, e2|
if order.first =~ /^(desc|reverse)/i
if (order.first || group_order.last) =~ /^(desc|reverse)/i
group_compare(keys.first,e2[0],e1[0])
else
group_compare(keys.first,e1[0],e2[0])
......@@ -213,7 +213,7 @@ module Jekyll
groups
else
groups.merge(groups) do |key,items|
grouper(items,keys.drop(1), order.length > 1 ? order.drop(1) : order)
grouper(items,keys.drop(1),order.drop(1))
end
end
end
......@@ -259,7 +259,7 @@ module Jekyll
def group_value(key,item)
case key
when 'type'
config['type_aliases'][item.type.to_s] || item.type.to_s
type_aliases[item.type.to_s] || item.type.to_s
else
value = item[key]
if value.numeric?
......@@ -295,6 +295,10 @@ module Jekyll
@type_order ||= config['type_order']
end
def type_aliases
@type_aliases ||= Scholar.defaults['type_aliases'].merge(config['type_aliases'])
end
def type_names
@type_names ||= Scholar.defaults['type_names'].merge(config['type_names'])
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment