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

Add a tutorials folder with simple tutorials #3622

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Agent-E11
Copy link

tutorials.md is the "home page"
The other md files are different sections (layout, technical, miscellaneous, etc.)

I have found it somewhat difficult getting started with eframe and I think it would be immensely helpful to have a collection of how-to's for doing small tasks (e.g. making a ui.group() the full available height).

This is (very) obviously not comprehensive, but I think it would be a good starting point. I am also not entirely sure about the layout, I think it's ok, but probably not perfect.


Addresses #186.

`tutorials.md` is the "home page"
The other `md` files are different sections (layout, technical, miscellaneous, etc.)
@emilk
Copy link
Owner

emilk commented Nov 27, 2023

Thanks for starting work on this!

The problem with this approach is code-rot: there is nothing checking that the code in the .md files are correct, and keep being correct as breaking changes land in egui.

I think a better approach is to collect these tricks into one tutorial application that users can compile and run.

If we embed it in the egui_demo_lib the tutorial can become a new section on egui.rs, which would link to its own source code, like most of the examples there already does.

Another alternative is to add them as doc-examples in the egui/src/lib.rs. That way we at least know they compil.e

@Agent-E11
Copy link
Author

@emilk
Ok.

  1. Would the "one tutorial application" go in egui/crates/egui_demo_lib?

  2. I think it could be hard to organize the small snippets if they are all in one application. (Maybe split it into the different categories like I did, but with separate apps instead of separate folders?)

  3. And, if they were in an application, would it be possible to search for specific tutorials?

  4. Looking through the examples in egui_demo_lib, I am having trouble figuring out how it works (it isn't laid out like a simple, single window app). Would it be possible to make the tutorial app simpler than the egui.rs site? (Single page, like the http demo) Possibly have it as another tab in egui.rs?

  5. Would it be possible to have the tutorial app's code in a separate folder? So that it is easy to browse the code?:

egui_demo_lib/src/tutorial
| - layout
|   | - bla-bla-bla
|
| - technical
|   | - bla-bla-bla
|
| - miscellaneous
|   | - bla-bla-bla
  1. I am realizing that this is getting really long, should I start a discussion?

@YgorSouza
Copy link
Contributor

YgorSouza commented Feb 10, 2024

You can make cargo test test .md files by including them in a crate or module's documentation with e.g. #![doc = include_str!("../../../README.md")]. They will be tested even if the module is private, so you could add hidden modules to some crate just for that.

Edit: but the problem with that is you have less control over how the code is displayed vs how it is run in the tests. For example, you can't have some hidden lines that set up the imports and variables so the code is valid, but are not rendered because they are not important. So maybe it would make more sense to just write a book with mdbook, which was made for that anyway.

@Agent-E11 Agent-E11 marked this pull request as draft February 27, 2024 22:31
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.

3 participants