Skip to content

Fixing code examples, statement about working tests on code examples #51

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

Closed
wants to merge 3 commits into from

Conversation

llogiq
Copy link
Contributor

@llogiq llogiq commented Jan 12, 2017

This doctests all code examples. There is some fallout to either ignore examples (if I deemed them too far from runnable) or change them to work, or at least compile.

I also added a .travis.yml so we can use CI to check PRs.

fixes #49

@nrc
Copy link
Collaborator

nrc commented Jan 13, 2017

Hmm, I wonder how worthwhile this is - it found one bug (which is nice), but I feel like every example which gets changed has got more cluttered and less easily understandable and that doesn't feel like a great trade-off to me.

@lambda-fairy
Copy link
Collaborator

Rustdoc lets you hide setup code by prefixing it with #, but I'm not sure how that'll help in our case.

@llogiq
Copy link
Contributor Author

llogiq commented Jan 13, 2017

I see two ways going forward:

  • write a build script that skips lines starting with # within code blocks, publish to github-pages
  • create an examples subdirectory containing complete runnable examples that can be playpen-linked, link them from the inline-examples.

Perhaps we can even do both and have the script build the examples?

@lambda-fairy
Copy link
Collaborator

See also #6 and #44. It would be nice to publish this to a standalone website one day.

Having a separate examples directory doesn't feel right, somehow. I think it's because the examples are so short that splitting them out into separate files won't be worth the extra effort. Maintaining a separate set of examples may raise the barrier to entry for contributors as well.

Also, since rustbook is built on top of rustdoc, I think it'll strip # lines already.

@llogiq
Copy link
Contributor Author

llogiq commented Jan 14, 2017

The idea is to have playground links. I'm not sure if this requires a canonical location per example or if the code gets embedded as link data.

@lambda-fairy
Copy link
Collaborator

lambda-fairy commented Jan 14, 2017

Okay, I see what you're aiming for with the playground.

As prior art, the official Rust book has playground links -- e.g. see the section on lifetimes. It looks like they use the # prefix solution, displaying the pretty code in the book but linking to the full code on the playground.

Unless there are further issues with their approach, I'm keen to just copy what they do.

@llogiq
Copy link
Contributor Author

llogiq commented Jan 14, 2017

Agreed. I'll look into that. Perhaps I should pare down this PR to the one fix I found then.

@DaseinPhaos DaseinPhaos mentioned this pull request Feb 15, 2017
@pickfire
Copy link
Contributor

Ping

@simonsan simonsan added the C-enhancement Category: Enhancements to content label Dec 31, 2020
@simonsan
Copy link
Collaborator

simonsan commented Dec 31, 2020

Small feedback (imho): I think it would be better at this stage to use Github Actions for that instead of Travis.

See next comment.

@lambda-fairy
Copy link
Collaborator

mdbook has a built-in doctest feature as well, which would make this PR redundant.

https://rust-lang.github.io/mdBook/cli/test.html

@simonsan
Copy link
Collaborator

simonsan commented Dec 31, 2020

mdbook has a built-in doctest feature as well, which would make this PR redundant.

https://rust-lang.github.io/mdBook/cli/test.html

Thanks for the heads-up, indeed, that looks like it would make it redundant when we convert this into a mdbook.

ref.: #6

@simonsan simonsan added the C-waiting for Category: Waiting for feedback of the initial author or some external dependency/issue label Dec 31, 2020
@simonsan simonsan changed the title doctest the examples Fixing code examples, statement about working tests on code examples Jan 1, 2021
@simonsan simonsan added S-lgtm Status: Let's get this merged and removed C-waiting for Category: Waiting for feedback of the initial author or some external dependency/issue labels Jan 1, 2021
@simonsan simonsan requested a review from marcoieni January 1, 2021 13:31
@simonsan
Copy link
Collaborator

simonsan commented Jan 1, 2021

Seems good to me, @marcoieni any additions?

@llogiq llogiq closed this Jan 1, 2021
@simonsan
Copy link
Collaborator

simonsan commented Jan 1, 2021

Hey @llogiq is there any reason you're closing this? There are still changes to be merged from your PR that are not the concerning the doctests or Travis, I already edited your branch to remove the parts and changed the title.

@simonsan simonsan added C-waiting for Category: Waiting for feedback of the initial author or some external dependency/issue C-zombie Category: A PR/an Issue that might be still useful but was closed and removed S-lgtm Status: Let's get this merged labels Jan 1, 2021
@simonsan
Copy link
Collaborator

simonsan commented Jan 2, 2021

Added the statement of working code examples to the template.md in #123 . What about the additions to the examples and rust, ignore? Do we still want to merge that from this PR?

Added them in #124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancements to content C-waiting for Category: Waiting for feedback of the initial author or some external dependency/issue C-zombie Category: A PR/an Issue that might be still useful but was closed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc --test the examples
5 participants