Skip to content

Conversation

doup
Copy link
Contributor

@doup doup commented Mar 7, 2025

Objective

Separate example explanation (file docblock) and the code so they can be layout differently in the website and we can give a higher importance to the explanation on the website search tool. This would also allow us to improve the examples so they become even more like a cookbook.

Solution

Update the example-showcase tool to extract the example file docblock and write it as the example markdown content. This allows us to access the explanation via page.content in Zola.

Testing

I've checked that the output is correct after running the tool and it doesn't throw any error. I've also validated that the approach will work on the website.

Showcase

This is a quick and dirty example of what we could do in the web examples after the change. When we implement the real thing we can put the explanation on a sidebar or explore other layout options.

image

@alice-i-cecile alice-i-cecile requested a review from mockersf March 8, 2025 21:53
@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples A-Cross-Cutting Impacts the entire engine X-Uncontroversial This work is generally agreed upon S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Mar 8, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 18, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 18, 2025
Copy link
Contributor

@krunchington krunchington left a comment

Choose a reason for hiding this comment

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

The rust specification does allow for inner doc comments anywhere in the file, but that seems like a case that's not super worth putting a ton of time into handling. This does appear to be a clear improvement over the alternative. Personally I don't mind reading the inner doc comments in the code block, but see little risk in this approach.

edit: didn't realize this was already in the merge queue. Well... "and my axe!" I suppose.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 19, 2025
@mockersf
Copy link
Member

The rust specification does allow for inner doc comments anywhere in the file, but that seems like a case that's not super worth putting a ton of time into handling. This does appear to be a clear improvement over the alternative. Personally I don't mind reading the inner doc comments in the code block, but see little risk in this approach.

Here we have control of where the doc comment we want is, so not a problem 🙂

Merged via the queue into bevyengine:main with commit faef6d1 Mar 19, 2025
38 checks passed
@mockersf mockersf added this to the 0.16 milestone Mar 19, 2025
mockersf pushed a commit that referenced this pull request Mar 19, 2025
…kdown (#18191)

# Objective

Separate example explanation (file docblock) and the code so they can be
layout differently in the website and we can give a higher importance to
the explanation on the [website search
tool](bevyengine/bevy-website#1935). This would
also allow us to improve the examples so they become even more like a
cookbook.

## Solution

Update the `example-showcase` tool to extract the example file docblock
and write it as the example markdown content. This allows us to access
the explanation via `page.content` in Zola.

## Testing

I've checked that the output is correct after running the tool and it
doesn't throw any error. I've also validated that the approach will work
on the website.

## Showcase

This is a quick and dirty example of what we could do in the web
examples after the change. When we implement the real thing we can put
the explanation on a sidebar or explore other layout options.

<img width="1362" alt="image"
src="https://github.com/user-attachments/assets/6738542e-31c3-41cd-972a-7fa2e942e85d"
/>
@doup doup deleted the split-example-docblock-and-code branch March 19, 2025 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Cross-Cutting Impacts the entire engine C-Examples An addition or correction to our examples D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants