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

Fix double trailing newline apidoc #7940

Merged
merged 3 commits into from
Jul 12, 2020

Conversation

AleksaC
Copy link
Contributor

@AleksaC AleksaC commented Jul 10, 2020

Subject: Fix apidoc generating two newlines at the end of the package rst file if it contains submodules and --module-first is used.

Feature or Bugfix

  • Bugfix

Purpose

{%- for submodule in submodules %}
{% if show_headings %}
{{- [submodule, "module"] | join(" ") | e | heading(2) }}
{% endif %}
{{ automodule(submodule, automodule_options) }}
{% endfor %}
{%- endif %}
{%- endif -%}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using stripping mark at both start and end causes template maintainable. I guess the change above (changing "else" to independent "if" statement) came from this change, right? To keep templates clean, it is better to use one of them consistently.

How about the change like this?

@@ -43,9 +46,10 @@ Submodules
 {{ automodule(submodule, automodule_options) }}
 {% endfor %}
 {%- endif %}
-{% endif %}
+{%- endif %}

 {%- if not modulefirst and not is_namespace %}
+
 Module contents
 ---------------

Notes:

  • Inserts a blank line before section headers to add a space only if the block needed.
  • Add stripping-mark to the start of "endif" to strip trailing return codes.

I guess some additional change would be needed for this change. But it will keep our templates clean (if my understanding correct). Could you check this please?

@AleksaC
Copy link
Contributor Author

AleksaC commented Jul 11, 2020

Thanks for the feedback. I tried what you suggested, but test_pep_0420_enabled_separate fails as the file lacks newline at the end and there is no clean way to add it. Another problem occurs with modules without submodules where 2 newlines are added before Module contents.

If using - both at the start and the end of the template is a problem it can be moved to the beginning of the next {% endif %}, but even that won't be necessary as I found a way to fix this even without changing else to a separate if statement.

@tk0miya
Copy link
Member

tk0miya commented Jul 12, 2020

Thank you for update. LGTM!

@tk0miya tk0miya merged commit d45d02f into sphinx-doc:3.x Jul 12, 2020
tk0miya added a commit that referenced this pull request Jul 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

apidoc generates an extra newline at the end of the rst file if a module has submodules
2 participants