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

Put the table back in 'table of contents'! #5

Open
wants to merge 2 commits into
base: fix/npe-when-body-undefined
Choose a base branch
from

Conversation

greglockwood
Copy link
Owner

@greglockwood greglockwood commented Jan 9, 2021

PR Description
realyze#30 Added ability to customise the base branch
#3 Fixed bug where branches were always being pushed
#4 Cater for body being nullish or empty
👉 #5 Putting the table back in 'table of contents'!
#6 Added support to print links to PRs in terminal
#7 Work when remote URL doesn't have .git suffix
realyze#31 [combined branch] Combined changes

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 are text or table. If table is set, a format matching what Alex suggested is used for the TOC (Table of Contents) instead. The default value is text, 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.

@greglockwood greglockwood force-pushed the feature/table-format-for-toc branch 2 times, most recently from 08da522 to 714c42b Compare January 9, 2021 15:17
@greglockwood greglockwood changed the title Added support for table format for TOC Put the table back in 'table of contents'! Jan 11, 2021
github.js Outdated
}
});
if (format === 'table') {
contents += table(tableData, { stringLength: width }) + '\n';
Copy link
Owner Author

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.

@alextreppass
Copy link

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) => {
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants