-
Notifications
You must be signed in to change notification settings - Fork 0
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
Put the table back in 'table of contents'! #5
base: fix/npe-when-body-undefined
Are you sure you want to change the base?
Put the table back in 'table of contents'! #5
Conversation
9b0bda0
to
baf00e3
Compare
08da522
to
714c42b
Compare
1c5dec2
to
9b06836
Compare
714c42b
to
48544bc
Compare
github.js
Outdated
} | ||
}); | ||
if (format === 'table') { | ||
contents += table(tableData, { stringLength: width }) + '\n'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the string-width
module here works around the strange rules for the width of emoji characters to end up with a table with much more aligned delimiters between columns.
Thanks for opening this @greglockwood! Looking forward to using it :) |
function constructTrainNavigation(branchToPrDict, currentBranch, combinedBranch, format) { | ||
let contents = '<pr-train-toc>\n\n'; | ||
let tableData = [['', 'PR', 'Description']]; | ||
Object.keys(branchToPrDict).forEach((branch) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think the table
format reads quite a lot nicer than the text
one - so I don't think we need to support both. Could we remove the format option and simply always render a table? That should simplify things a bit. WDYT?
# Conflicts: # cfg_template.yml # consts.js # github.js # index.js
9b06836
to
b55bc33
Compare
48544bc
to
67f8efb
Compare
Which problem does this PR solve?
As suggested by @alextreppass in realyze#17, it would be nice to support displaying the table of contents in an actual table format.
Main changes
This PR adds a new config option,
prs.toc-format
to the.pr-train.yml
. Valid values aretext
ortable
. Iftable
is set, a format matching what Alex suggested is used for the TOC (Table of Contents) instead. The default value istext
, making this an opt-in feature for now.Related documents/resources
See previous PRs (i.e. realyze#30) for more details about the addition of the
prs
section to the config file.How I tested it works
I tested this in my own test repository. One example.