- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Only show authors' email addresses if so configured in git-authors #6494
Conversation
b2b6f55
to
c34101e
Compare
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.
Minor cosmetic changes, otherwise good!
<a href="mailto:{{ author.email }}"> | ||
{{- author.name -}} | ||
</a> | ||
{%- if show_email_address %}<a href="mailto:{{ author.email }}">{{- author.name -}}</a>{%- else -%}{{- author.name -}}{% endif -%} |
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.
This is not really readable. Please adhere to the surrounding formatting, so move things onto separate lines. There's also no need to put show_email_address
in a separate variable I think.
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.
Roger that, updated.
c34101e
to
9c32490
Compare
@@ -54,9 +55,11 @@ | |||
</span> | |||
<nav> | |||
{% for author in authors %} | |||
<a href="mailto:{{ author.email }}"> | |||
{%- if git_authors.config.show_email_address %} |
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.
One more spot: We don't need whitespace control here. Please remove the -
on all tags that you added.
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.
Does that include the one instance of {{- author.name -}}
that I duplicated? In other words, should the hyphens be dropped from that one as well?
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.
Yes. The following line is the only line where this is necessary, because we want the ,
to stick to the author name, but this is a line you did not touch, which is why I meant to remove them from all lines you touched.
{%- if loop.revindex > 1 %}, {% endif -%} |
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.
Also, I am not so sure about that. If I drop all instances of -
that I introduced here, then if show_email_address
is true
, I end up with
<nav>
<a href="mailto:john.doe@example.com">John Doe</a>
,
<a href="mailto:jane.doe@example.com">Jane Doe</a>
</nav>
And I'm pretty sure we don't want that comma on its own line, because it gets rendered as
... and the thus-appearing extra whitespace before the comma is extraneous.
As the patch is currently proposed, what we end up with is
<nav>
<a href="mailto:john.doe@example.com">John Doe</a>,
<a href="mailto:jane.doe@example.com">Jane Doe</a>
</nav>
... which is what we want, I think. Would you agree?
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've just pushed 7f0cdd2 which is the most minimal patch that I can think of, with no whitespace management added at all. But that introduces the extra space before the comma, no matter if we're rendering a link or not. So please do not merge that as-is.
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.
That fixes things only for show_email_address: false
; but still breaks (i.e. introduces the extraneous whitespace) for the default of show_email_address: true
.
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.
This does the right thing, regardless of how show_email_address
is set:
{% for author in authors %}
+ {%- if git_authors.config.show_email_address %}
<a href="mailto:{{ author.email }}">
{{- author.name -}}
</a>
+ {%- else -%}
+ {{- author.name -}}
+ {% endif -%}
{%- if loop.revindex > 1 %}, {% endif -%}
{% endfor %}
Okay if I update my topic branch with that?
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'm sure you don't need all of those whitespace control characters, but okay, let's keep the whitespace control. I'll look into in the future. We should keep whitespace control to a minimum, and only use it where absolutely necessary.
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 sympathise with that, but if you instruct me to "remove the -
on all tags that [I] added" and simultaneously "we want the ,
to stick to the author name", I can only do one xor the other. :)
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.
Haha yeah, sorry for that. Entirely my fault. I'm sorry for the back and forth. Is it okay to merge now?
9c32490
to
7f0cdd2
Compare
Honour the git-authors plugin's setting to render the authors' names as links pointing to their email address: * If the git-authors plugin is enabled and its show_email_address option is not set, or is set to true, render the author's name as a "mailto:" link. * If the git-authors plugin is enabled and its show_email_address option is set to false, render the author's name in plain text with no link. * If the git-authors plugin is not enabled (or not installed), don't show author information.
7f0cdd2
to
518d617
Compare
What will probably become mkdocs-material 9.5.3 gives us the ability to again render authors' names without them turning into "mailto:" links. Thus, require that as the minimum version. Since it is now mkdocs-material that natively renders author information, we no longer need the theme override for main.html. References: https://squidfunk.github.io/mkdocs-material/setup/adding-a-git-repository/#document-authors squidfunk/mkdocs-material#6494
Well I'd still been trying to wrap my head around how to add tests for this, hence the Draft mode. I've looked at what I think is the relevant part of the docs, but most of those recommendations don't seem to apply here since neither mkdocs-material's own docs nor the examples repo use I've tested it against the repo I co-maintain (citynetwork/docs#257) and there all our tests pass. Is that sufficient? |
Yes, that should be fine. Thanks! |
What will probably become mkdocs-material 9.5.3 gives us the ability to again render authors' names without them turning into "mailto:" links. Thus, require that as the minimum version. Since it is now mkdocs-material that natively renders author information, we no longer need the theme override for main.html. References: https://squidfunk.github.io/mkdocs-material/setup/adding-a-git-repository/#document-authors squidfunk/mkdocs-material#6494
mkdocs-material 9.5.3 gives us the ability to again render authors' names without them turning into "mailto:" links. Thus, require that as the minimum version. Since it is now mkdocs-material that natively renders author information, we no longer need the theme override for main.html. References: https://squidfunk.github.io/mkdocs-material/setup/adding-a-git-repository/#document-authors squidfunk/mkdocs-material#6494
Honour the
git-authors
plugin's option to render the authors' names as links pointing to their email address:git-authors
plugin is enabled and itsshow_email_address
option is not set, or is set totrue
1, render the author's name as amailto:
link.git-authors
plugin is enabled and itsshow_email_address
option is set tofalse
, render the author's name in plain text with no link.git-authors
plugin is not enabled (or not installed), don't show author information.Footnotes
The current default for
show_email_address
in the plugin istrue
. If that default ever changes in the future, then the logic for showing themailto:
link would change accordingly. ↩