diesel-rs / diesel

A safe, extensible ORM and Query Builder for Rust
https://diesel.rs
Apache License 2.0
12.77k stars 1.07k forks source link

Better Documentation #853

Closed theduke closed 6 years ago

theduke commented 7 years ago

I think lack of documentation is a huge road block for Diesel adoption.

Each time I try to get started with Diesel, I have to struggle hard to not drop it and just use one of the raw database libraries.

The guide is VERY basic, and the source docs don't offer much either.

I would imagine I'm not the only one suffering from such frustration.

As a positive example that could be emulated, I think Rocket has managed a very decent, well structured guide that makes it easy to get started with and use.

killercup commented 7 years ago

Yep!

Any concrete ideas what the documentation needs to cover that is currently missing? We want to add more guides (there is one PR to add a guide on updates), and any indicator what is needed the most would be helpful. :)

theduke commented 7 years ago

@killercup You have probably put more thought into it, but, off the top of my head, here is a raw structure for the documentation.

theduke commented 7 years ago

I'd recommend not just writing more guides, but writing a structured documentation like above that can also be used as a sort of reference to quickly look up how to do certain things.

Especially with a ORM that's very valuable, imo.

I'm not in love with how https://github.com/azerupi/mdBook looks, but it's good enough for Rust, so using that might be an option, and certainly less work than building something custom.

alanhdu commented 7 years ago

To add my two cents:

The single biggest thing that'd make Diesel easier to learn is to add way more examples. Basic SELECT, INSERT, DELETE, and UPDATE queries are covered already, but for anything non-trivial it was much easier to look at Diesel's tests than at the API docs. Honestly, I think finding some SQL tutorial somewhere and documenting how to do every single query with Diesel would be a huge improvement.

In particular:

alanhdu commented 7 years ago

Oh and also... I'm not sure how feasible this is, but I'd love a guide on how to read Diesel's compilation errors. They get pretty nasty, and sometimes I honestly have no clue how to use them to figure out what's wrong.

theduke commented 7 years ago

To suuport what @alanhdu said, i think the Queries section in my outline is by far the most important.

DavidBM commented 7 years ago

One think that I miss, is a list of all possible items. Like possible annotations for models in the struct. Sometimes, just a list of all the items helps as an index to see the possibilities.

Is not to make the information more easy to read, is to have a entry point to see all the information.

Now I'm searching if there is any annotation for telling diesel that ignore one field of the struct. I'm searching in the issues, in google, in the docs, but I don't find any place with all the possible functions, macros, annotations, etc of Diesel. In other frameworks I can read the full documentation in case of not finding the answer, here... there is no "all documentation".

As @alanhdu says in https://github.com/diesel-rs/diesel/issues/853#issuecomment-292817084 in the last point, a list of things that can be done.

blanham commented 7 years ago

Perhaps it might make sense to create a new repo specifically for the diesel.rs homepage? At the very least the existing guide could be expanded.

sgrif commented 7 years ago

The repo homepage is sgrif/diesel.rs-website

killercup commented 7 years ago

Just as a heads up to others, @hobofan said he'd like to start a query builder guide, and @notryanb want to document model derives/traits.

notryanb commented 7 years ago

Update - I'm currently working on updating the Associations docs for v1.0 and a separate guide for Joins.

aliyazdani commented 6 years ago

I'd love to see more docs too - especially for sqlite. This is my first try at Diesel with Sqlite3. Most of the examples I find are for PG and unfortunately we don't have that option atm. The examples on the repo for sqlite are extremely basic. I managed to get my inserts and updates working but a basic select query is generating a ton of compiler errors that are hard to understand. I can't imagine what a join requires.

I'd be happy to lend a hand if needed (even though I'm still a Rust noob at this point). Thanks!

sgrif commented 6 years ago

Once all open doc PRs today are merged, we will be able to add #![deny(missing_docs)] to the repo. #1407 (hopefully) addresses the "I don't know where to find things" issue (please comment on that PR with your feedback though). I've reviewed every single piece of documentation in the library over the past few weeks to make sure it's up to date (I likely missed a module somewhere, please open an issue if you find anything that is out of date or poorly documented). I'm hoping to publish ~10 more guides before the end of the year.

I realize not everything is documented as perfectly as it could be. If you have any concrete places where the documentation could be improved (even if it's just "I couldn't find/figure out X, here's where I looked") please open an issue.

However, I think we have sufficiently resolved the issue of "our docs generally suck" enough to close this.

kostya-sec commented 6 years ago

i have readed the document. but i still dont know how to use "use schema::posts::dsl::*". diesel created these models or i have to write by myself? i really dont know how to do it.