Submitter | Thomas De Schampheleire |
---|---|
Date | Aug. 25, 2014, 1:41 p.m. |
Message ID | <6dd4d3afa394f86e2996.1408974088@localhost> |
Download | mbox | patch |
Permalink | /patch/5595/ |
State | Accepted |
Headers | show |
Comments
On Mon, 2014-08-25 at 15:41 +0200, Thomas De Schampheleire wrote: > # HG changeset patch > # User Thomas De Schampheleire <thomas.de.schampheleire@gmail.com> > # Date 1408972209 -7200 > # Mon Aug 25 15:10:09 2014 +0200 > # Node ID 6dd4d3afa394f86e29968aaaed6f25712c6cde9f > # Parent 90cf454edd709c616d1e5ea4f30fb4d02f0c01a4 > help: add pad function to template help > > Commit aa51392da507 introduced a pad function for use in templates, but did > not add the corresponding documentation to 'hg help templating'. > > diff --git a/mercurial/help/templates.txt b/mercurial/help/templates.txt > --- a/mercurial/help/templates.txt > +++ b/mercurial/help/templates.txt > @@ -57,6 +57,8 @@ > > - label(label, expr) > > +- pad(text, width[, fillchar, right]) > + I could hardly call this "documentation". I'm preparing a fix to actually say what all of these functions *do*, since it's not documented anywhere. I suppose you can sort of guess for some of them, but overall it's still fairly obscure. Can you come up with a one-line explanation of what this function does? I think it's reasonable to give one-line descriptions of what all of these do. Very important to keep it short, but not nonexistent. Also, this needs an example, if nothing else. - Jordi G. H.
Hi Jordi, On Mon, Aug 25, 2014 at 4:30 PM, Jordi Gutiérrez Hermoso <jordigh@octave.org> wrote: > On Mon, 2014-08-25 at 15:41 +0200, Thomas De Schampheleire wrote: >> # HG changeset patch >> # User Thomas De Schampheleire <thomas.de.schampheleire@gmail.com> >> # Date 1408972209 -7200 >> # Mon Aug 25 15:10:09 2014 +0200 >> # Node ID 6dd4d3afa394f86e29968aaaed6f25712c6cde9f >> # Parent 90cf454edd709c616d1e5ea4f30fb4d02f0c01a4 >> help: add pad function to template help >> >> Commit aa51392da507 introduced a pad function for use in templates, but did >> not add the corresponding documentation to 'hg help templating'. >> >> diff --git a/mercurial/help/templates.txt b/mercurial/help/templates.txt >> --- a/mercurial/help/templates.txt >> +++ b/mercurial/help/templates.txt >> @@ -57,6 +57,8 @@ >> >> - label(label, expr) >> >> +- pad(text, width[, fillchar, right]) >> + > > I could hardly call this "documentation". I'm preparing a fix to > actually say what all of these functions *do*, since it's not > documented anywhere. I suppose you can sort of guess for some of them, > but overall it's still fairly obscure. True. I was merely following the existing approach, but 'real' documentation would be even better. > > Can you come up with a one-line explanation of what this function > does? I think it's reasonable to give one-line descriptions of what > all of these do. Very important to keep it short, but not nonexistent. > > Also, this needs an example, if nothing else. While I can use the first two mandatory arguments without problem, specifying an alternate padding character, or specifying right-padding doesn't work for me. Durham Goode, the original author of the function, could probably help here. This works: hg log -l3 --template 'X {pad(author|person, 40)} X\n' but hg log -l3 --template 'X {pad(author|person, 40,_)} X\n' hg log -l3 --template 'X {pad(author|person, 40,'_')} X\n' or anything else I tried does not. Best regards, Thomas
On Mon, 2014-08-25 at 15:41 +0200, Thomas De Schampheleire wrote: > # HG changeset patch > # User Thomas De Schampheleire <thomas.de.schampheleire@gmail.com> > # Date 1408972209 -7200 > # Mon Aug 25 15:10:09 2014 +0200 > # Node ID 6dd4d3afa394f86e29968aaaed6f25712c6cde9f > # Parent 90cf454edd709c616d1e5ea4f30fb4d02f0c01a4 > help: add pad function to template help Taking this as is since it's obviously an incremental improvement. I've put this on stable since it's a doc fix, please use --flag stable in the future. Folks, feel free to follow-up with more detailed docs.
On 8/26/14, 10:12 AM, "Thomas De Schampheleire" <patrickdepinguin+mercurial@gmail.com> wrote: >While I can use the first two mandatory arguments without problem, >specifying an alternate padding character, or specifying right-padding >doesn't work for me. > >Durham Goode, the original author of the function, could probably help >here. > >This works: >hg log -l3 --template 'X {pad(author|person, 40)} X\n' > >but >hg log -l3 --template 'X {pad(author|person, 40,_)} X\n' >hg log -l3 --template 'X {pad(author|person, 40,'_')} X\n' >or anything else I tried does not. Your quoting is off for that last example. Need “” instead of ‘’ around the _. ~/hg> hg log -r . -T 'X {pad(author|person, 40,"_")} X\n' X Durham Goode____________________________ X ~/hg> hg log -r . -T 'X {pad(author|person, 40,"_", True)} X\n' X ____________________________Durham Goode X
On Tue, Aug 26, 2014 at 12:30 PM, Durham Goode <durham@fb.com> wrote: > On 8/26/14, 10:12 AM, "Thomas De Schampheleire" > <patrickdepinguin+mercurial@gmail.com> wrote: > >>While I can use the first two mandatory arguments without problem, >>specifying an alternate padding character, or specifying right-padding >>doesn't work for me. >> >>Durham Goode, the original author of the function, could probably help >>here. >> >>This works: >>hg log -l3 --template 'X {pad(author|person, 40)} X\n' >> >>but >>hg log -l3 --template 'X {pad(author|person, 40,_)} X\n' >>hg log -l3 --template 'X {pad(author|person, 40,'_')} X\n' >>or anything else I tried does not. > > Your quoting is off for that last example. Need “” instead of ‘’ around > the _. > > ~/hg> hg log -r . -T 'X {pad(author|person, 40,"_")} X\n' > X Durham Goode____________________________ X > ~/hg> hg log -r . -T 'X {pad(author|person, 40,"_", True)} X\n' > X ____________________________Durham Goode X > Ah yes, stupid mistake, thanks! Jordi, I think a one-line description could be: pad 'text' up to 'width' characters using 'fillchar' (default: ' '). Set 'right' to True to right-align the text. Clearly, this assumes that the user knows what 'padding' means. Best regards, Thomas
Patch
diff --git a/mercurial/help/templates.txt b/mercurial/help/templates.txt --- a/mercurial/help/templates.txt +++ b/mercurial/help/templates.txt @@ -57,6 +57,8 @@ - label(label, expr) +- pad(text, width[, fillchar, right]) + - revset(query[, formatargs]) - rstdoc(text, style)