Skip to content

Fix generated docs example closing fences#1548

Open
omribz156 wants to merge 1 commit into
appwrite:masterfrom
omribz156:codex/docs-example-fence-newline
Open

Fix generated docs example closing fences#1548
omribz156 wants to merge 1 commit into
appwrite:masterfrom
omribz156:codex/docs-example-fence-newline

Conversation

@omribz156
Copy link
Copy Markdown

What

This keeps generated PHP and .NET example code fences on their own line after multi-parameter calls.

The current generated docs can produce lines like:

);```

which makes the closing Markdown fence part of the code sample instead of ending the block cleanly.

Why

The reported .NET issue comes from generated examples in appwrite/specs, and those examples are produced from these sdk-generator docs templates. While checking the generated source, I found the same fence pattern in the PHP examples too, so this adjusts both matching templates.

Refs appwrite/appwrite#12333.

Verification

  • uvx djlint templates/dotnet/docs/example.md.twig templates/php/docs/example.md.twig --lint
  • Not run: full SDK regeneration/tests. This local machine does not have PHP, Composer, or Docker available.

This was implemented with Codex assistance and manually reviewed before opening the PR.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 19, 2026

Greptile Summary

This PR fixes a Twig whitespace bug in the PHP and .NET doc example templates where ); was appearing on the same line as the closing code fence ```, breaking the Markdown block. The root cause is that Twig automatically removes the first newline after a block tag: when {% if condition %});{% endif %} occupied the last template line before ```, the {% endif %} consumed the separating newline. Moving ); onto its own line between {% if %} and {% endif %} places the sole separator newline on the ); line, which is not adjacent to any block tag.

  • .NET: {% if condition %});{% endif %} split so ); sits between the two tags on its own line; the pre-existing blank line above ); is unchanged.
  • PHP: Same split applied; -%} is also removed from {%~ endfor -%}, which is functionally neutral since there is only one between the endfor and {% if %} and Twig's default first-newline removal already consumes it.

Confidence Score: 5/5

Safe to merge — the change is a two-line template restructure that cleanly separates a closing parenthesis from the Markdown fence without touching any logic or runtime code.

Both changed templates have a single, well-understood edit: the closing ); is moved to its own template line so Twig's automatic post-tag newline removal no longer collapses it into the code fence. The PHP removal of -%} from {%~ endfor -%} is verified to be a no-op (only one newline follows the tag, which Twig's default behavior already strips). The zero-parameter path is unchanged in both files. No other template files or logic are touched.

No files require special attention.

Important Files Changed

Filename Overview
templates/dotnet/docs/example.md.twig Correctly splits the inline {% if condition %});{% endif %} so ); has its own line; fixes the fence-collision bug without any new issues.
templates/php/docs/example.md.twig Same fix as .NET plus removal of -%} from {%~ endfor -%}; the removal is functionally neutral and the fence-collision bug is resolved.

Reviews (1): Last reviewed commit: "fix(docs): keep example fences on their ..." | Re-trigger Greptile

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.

1 participant