chiark / gitweb /
documentation: tighten up writing of trailing newlines.
authorVladimír Vondruš <mosra@centrum.cz>
Thu, 26 Sep 2024 16:41:17 +0000 (18:41 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 28 Sep 2024 01:44:29 +0000 (03:44 +0200)
documentation/doxygen.py
documentation/python.py

index 3bb13b86b15f543d2b9be7c3ab7d52d2f7140847..d3ef69ebba38d40fdfaa9f44caff8a47cd4071e7 100755 (executable)
@@ -4148,7 +4148,9 @@ def run(state: State, *, templates=default_templates, wildcard=default_wildcard,
                     # Add back a trailing newline so we don't need to bother
                     # with patching test files to include a trailing newline to
                     # make Git happy. Can't use keep_trailing_newline because
-                    # that'd add it also for nested templates :(
+                    # that'd add it also for nested templates :( The rendered
+                    # file should never contain a trailing newline on its own.
+                    assert not rendered.endswith('\n')
                     f.write(b'\n')
         else:
             parsed = parse_xml(state, file)
@@ -4168,7 +4170,9 @@ def run(state: State, *, templates=default_templates, wildcard=default_wildcard,
                 # Add back a trailing newline so we don't need to bother with
                 # patching test files to include a trailing newline to make Git
                 # happy. Can't use keep_trailing_newline because that'd add it
-                # also for nested templates :(
+                # also for nested templates :( The rendered file should never
+                # contain a trailing newline on its own.
+                assert not rendered.endswith('\n')
                 f.write(b'\n')
 
     # Empty index page in case no mainpage documentation was provided so
@@ -4195,7 +4199,9 @@ def run(state: State, *, templates=default_templates, wildcard=default_wildcard,
             # Add back a trailing newline so we don't need to bother with
             # patching test files to include a trailing newline to make Git
             # happy. Can't use keep_trailing_newline because that'd add it
-            # also for nested templates :(
+            # also for nested templates :( The rendered file should never
+            # contain a trailing newline on its own.
+            assert not rendered.endswith('\n')
             f.write(b'\n')
 
     if not state.config['SEARCH_DISABLED']:
@@ -4223,7 +4229,9 @@ def run(state: State, *, templates=default_templates, wildcard=default_wildcard,
                 # Add back a trailing newline so we don't need to bother with
                 # patching test files to include a trailing newline to make Git
                 # happy. Can't use keep_trailing_newline because that'd add it
-                # also for nested templates :(
+                # also for nested templates :( The rendered file should never
+                # contain a trailing newline on its own.
+                assert not rendered.endswith('\n')
                 f.write(b'\n')
 
     # Copy all referenced files
index dddc932134a0f5d955cb2383d286fa808d7eebd9..37cb02fc6f5e7bb71a7462a655e1a9ef3343a79b 100755 (executable)
@@ -2060,7 +2060,9 @@ def render(*, config, template: str, url: str, filename: str, env: jinja2.Enviro
         # Add back a trailing newline so we don't need to bother with
         # patching test files to include a trailing newline to make Git
         # happy. Can't use keep_trailing_newline because that'd add it
-        # also for nested templates :(
+        # also for nested templates :( The rendered file should never contain a
+        # trailing newline on its own.
+        assert not rendered.endswith('\n')
         f.write(b'\n')
 
 def render_module(state: State, path, module, env):
@@ -2874,7 +2876,9 @@ def run(basedir, config, *, templates=default_templates, search_add_lookahead_ba
                 # Add back a trailing newline so we don't need to bother with
                 # patching test files to include a trailing newline to make Git
                 # happy. Can't use keep_trailing_newline because that'd add it
-                # also for nested templates :(
+                # also for nested templates :( The rendered file should never
+                # contain a trailing newline on its own.
+                assert not rendered.endswith('\n')
                 f.write(b'\n')
 
     # Copy referenced files