News for hackers. Stuff that matters.
Re:I'd like to review your README by noxer on Saturday April 17, 2021 @07:02AM (#26843301)
I wish people would find a way to include any code present in a README in some kind of automated test.

Nothing more frustrating than if you copy something from there but it turns out the README wasn't updated since the very first day and all the "hello world" code or install instructions are completely outdated

Maybe not include any code is the better solution, instead add an example folder.

Re:I'd like to review your README by Gadiguibou on Saturday April 17, 2021 @08:09AM (#26843669)
That's included in Rust![1]

Code examples from the documentation automatically become "documentation tests" to make sure your examples are still up to date when updating your code.

[1] https://doc.rust-lang.org/rustdoc/documentation-tests.html

Re:I'd like to review your README by Omin on Saturday April 17, 2021 @08:51AM (#26843858)
The README.md isn't part of the rust code, so it's not checked by this unless you use tools to generate your README from doc comments like https://github.com/livioribeiro/cargo-readme.
Re:I'd like to review your README by Rompect on Saturday April 17, 2021 @11:12AM (#26844815)
Actually, it's possible and even frequently used, for example in lazy-static, through the `doc_comment` crate.

    #[cfg(doctest)]
    #[macro_use]
    extern crate doc_comment;
    
    #[cfg(doctest)]
    doctest!("../README.md");
Now, the readme examples are tested like everything else.

https://github.com/rust-lang-nursery/lazy-static.rs/blob/mas...

Re:I'd like to review your README by thejosh on Saturday April 17, 2021 @09:33AM (#26844141)
I like this about elixir, in the documentation you can use exdoc to make sure that the code examples actually work, and provide code samples that are tested. It makes reading documentation for projects quite nice.
Re:I'd like to review your README by Liskni_si on Sunday April 18, 2021 @06:41AM (#26851358)
I've been using https://github.com/brodie/cram for this. It's a neat little shell testing tool that can be told to check that every 4-space indented markdown code block output what it says it outputs, so I just cram my README.md.

An example of this in action: https://github.com/liskin/liscopridge/blame/68a656b7beb10a5c..., https://github.com/liskin/liscopridge/blob/68a656b7beb10a5cd...

Re:I'd like to review your README by an_ko on Saturday April 17, 2021 @10:18AM (#26844439)
I've written this tool to test example code in markdown documents using user-specified shell commands: https://github.com/anko/txm I have had great success using it in my own projects, so perhaps others might find it useful too.
Re:I'd like to review your README by kstenerud on Saturday April 17, 2021 @07:44AM (#26843527)
One thing golang did right is the go playground. When I put code in my README, I also include a playground link.

Example: https://github.com/kstenerud/go-concise-encoding#library-usa...

Re:I'd like to review your README by franciscop on Saturday April 17, 2021 @07:15AM (#26843371)
I did that! I hope you are not the person who suffered that from me (did you use Picnic CSS a few years back?). So for a newer project I put some setup code that will look for all code snippets with a specific comment and run that with the code after the comment. For generating the website documentation that test bit can be stripped (though I kept it for now).

Example: https://github.com/franciscop/server/blob/master/docs/docume...

Re:I'd like to review your README by tele_ski on Saturday April 17, 2021 @12:42PM (#26845586)
This is great advice and I wish it was the standard. I had this problem on one of my projects so I used a githook to basically paste in actual compiled example files from the test suite on committing. It does mean the actual readme is more like a template and you can't edit the README file directly anymore but all the examples always work now!

I personally like at least one small example embedded in the README since it's zero effort, an example folder is great for _more_, but annoying to get started, what should I look at in the example folder first?

Re:I'd like to review your README by boxed on Saturday April 17, 2021 @03:01PM (#26846562)
You'll like this https://kodare.net/2020/10/23/100_percent_coverage_docs.html it's my journey to 100% coverage for all code samples in ALL the documentation for iommi.
Re:I'd like to review your README by SuperCuber on Saturday April 17, 2021 @10:38AM (#26844547)
I do something similar: my README contains the output of --help, and I have a CI step that ensures that all the lines of the actual help output are present in the README. Caught me a couple times forgetting to update new flags and version changes.
Re:I'd like to review your README by M3t0r on Saturday April 17, 2021 @12:03PM (#26845237)
I've spent hours putting that functionality into a unit test. Worth every minute!
Re:I'd like to review your README by ehershey on Saturday April 17, 2021 @10:46AM (#26844601)
This is brilliant!

It’s one of those things that’s so easy to forget or not even think about but once you see it or think about it, it’s essential.

Re:I'd like to review your README by kevin_thibedeau on Saturday April 17, 2021 @10:51AM (#26844643)
Generate it with an m4 include.