Skip to content

Commit fc461a9

Browse files
committed
Convert JavaDoc to Markdown
1 parent d1e47eb commit fc461a9

File tree

1 file changed

+56
-63
lines changed

1 file changed

+56
-63
lines changed

jablib/src/main/java/org/jabref/logic/layout/format/NameFormatter.java

Lines changed: 56 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,69 +9,62 @@
99
import org.jabref.logic.layout.LayoutFormatter;
1010
import org.jabref.model.entry.AuthorList;
1111

12-
/**
13-
* This layout formatter uses the Bibtex name.format$ method and provides ultimate flexibility:
14-
*
15-
* The formatter needs a parameter to be passed in that follows the following format:
16-
*
17-
* <code>&lt;case1>@&lt;range11>@"&lt;format>"@&lt;range12>@"&lt;format>"@&lt;range13>...@@
18-
*
19-
* &lt;case2>@&lt;range21>@...</code> and so on.
20-
*
21-
* Individual cases are separated by @@ and items in a case by @.
22-
*
23-
* Cases are just integers or the character * and will tell the formatter to apply the following formats if there are
24-
* less or equal authors given to it. The cases must be in strict increasing order with the * in the last position.
25-
*
26-
* For instance:
27-
*
28-
* case1 = 2
29-
* case2 = 3
30-
* case3 = *
31-
*
32-
* Ranges are either &lt;integer>..&lt;integer>, &lt;integer> or the character * using a 1 based index for indexing
33-
* authors from the given authorlist. Integer indexes can be negative to denote them to start from
34-
* the end of the list where -1 is the last author.
35-
*
36-
* For instance with an authorlist of "Joe Doe and Mary Jane and Bruce Bar and Arthur Kay":
37-
*
38-
* 1..3 will affect Joe, Mary and Bruce
39-
*
40-
* 4..4 will affect Arthur
41-
*
42-
* * will affect all of them
43-
*
44-
* 2..-1 will affect Mary, Bruce and Arthur
45-
*
46-
* The &lt;format> uses the Bibtex formatter format:
47-
*
48-
* The four letter v, f, l, j indicate the name parts von, first, last, jr which
49-
* are used within curly braces. A single letter v, f, l, j indicates that the name should be abbreviated.
50-
* To put a quote in the format string quote it using \" (mh. this doesn't work yet)
51-
*
52-
* I give some examples but would rather point you to the bibtex documentation.
53-
*
54-
* "{ll}, {f}." Will turn "Joe Doe" into "Doe, J."
55-
*
56-
* Complete example:
57-
*
58-
* To turn:
59-
*
60-
* "Joe Doe and Mary Jane and Bruce Bar and Arthur Kay"
61-
*
62-
* into
63-
*
64-
* "Doe, J., Jane, M., Bar, B. and Kay, A."
65-
*
66-
* you would use
67-
*
68-
* 1@*@{ll}, {f}.@@2@1@{ll}, {f}.@2@ and {ll}, {f}.@@*@1..-3@{ll}, {f}., @-2@{ll}, {f}.@-1@ and {ll}, {f}.
69-
*
70-
* Yeah this is trouble-some to write, but should work.
71-
*
72-
* For more examples see the test-cases.
73-
*
74-
*/
12+
/// This layout formatter uses the BibTeX `name.format$` method and provides ultimate flexibility.
13+
///
14+
/// The formatter needs a parameter with the following format:
15+
///
16+
/// ```
17+
/// <case1>@<range11>@"<format>"@<range12>@"<format>"@<range13>...@@
18+
/// <case2>@<range21>@...
19+
///```
20+
///
21+
/// Individual cases are separated by `@@` and items in a case by `@`.
22+
///
23+
/// Cases are just integers or the character `*` and tell the formatter to apply the following formats
24+
/// if there are less or equal authors given.
25+
/// The cases must be in strictly increasing order with `*` in the last position.
26+
///
27+
/// Example:
28+
/// - `case1 = 2`
29+
/// - `case2 = 3`
30+
/// - `case3 = *`
31+
///
32+
/// Ranges are either `<integer>..<integer>`, `<integer>` or `*` (using a 1-based index).
33+
/// Negative integers start from the end (`-1` = last author).
34+
///
35+
/// Example with `Joe Doe and Mary Jane and Bruce Bar and Arthur Kay`:
36+
/// - `1..3` → Joe, Mary, Bruce
37+
/// - `4..4` → Arthur
38+
/// - `*` → all authors
39+
/// - `2..-1` → Mary, Bruce, Arthur
40+
///
41+
/// The `<format>` uses the BibTeX formatter syntax:
42+
/// - The letters `v`, `f`, `l`, `j` indicate name parts (von, first, last, jr). Use them inside `{}` for full form.
43+
/// - A single letter (`v`, `f`, `l`, `j`) abbreviates the part.
44+
/// - Quotes must be escaped as `\"` (not fully supported yet).
45+
///
46+
/// Example:
47+
/// - `"{ll},{f}."` → `"Joe Doe"` becomes `"Doe, J."`
48+
///
49+
/// Complete example:
50+
///
51+
/// Input:
52+
/// ```
53+
/// Joe Doe and Mary Jane and Bruce Bar and Arthur Kay
54+
///```
55+
///
56+
/// Output:
57+
/// ```
58+
/// Doe, J., Jane, M., Bar, B. and Kay, A.
59+
///```
60+
///
61+
/// Formatter parameter:
62+
/// ```
63+
/// 1@*@{ll},{f}.@@2@1@{ll},{f}.@2@ and {ll},{f}.@@*@1..-3@{ll},{f}., @-2@{ll},{f}.@-1@ and {ll},{f}.
64+
///```
65+
///
66+
/// This is troublesome to write, but it works.
67+
/// For more examples see the test cases.
7568
public class NameFormatter implements LayoutFormatter {
7669

7770
public static final String DEFAULT_FORMAT = "1@*@{ff }{vv }{ll}{, jj}@@*@1@{ff }{vv }{ll}{, jj}@*@, {ff }{vv }{ll}{, jj}";

0 commit comments

Comments
 (0)