danburkert / lmdb-rs

Safe Rust bindings for LMDB
Apache License 2.0
172 stars 87 forks source link

Documentation doesn't clearly specify which flag constants belong to flag group #15

Closed cmbrandenburg closed 6 years ago

cmbrandenburg commented 7 years ago

Currently, it's difficult to discover all flags of a type without looking at the source. For example, if I want to find all possible WriteFlags values when writing code to put a value into a database, I open the flags.rs source file and look at the bitflags macro that defines them. Ditto when I need to find the possible values for DatabaseFlags and EnvironmentFlags.

Instead, the rustdoc-generated documentation should list all flags of a type in one place. I'm not sure where and how, but here are some ideas:

  1. List all relevant flag constants in the type definition (e.g., in the description for WriteFlags, list out APPEND, APPEND_DUP, CURRENT, etc.).
  2. Create a submodule for each flag type, which would force the documentation to group flags together by type.
  3. Explicitly describe the flags and what they do in the description for each method that has a flag parameter. For example, in the RwTransaction::put method, specify all WriteFlags values and what effect they have.

Items 1 and 2, above, are the easiest to implement, though I think item 3 gives the best user experience. Of course, the items aren't mutually exclusive and good documentation is often repetitive instead of maximally concise.

Here are all affected flag types:

danburkert commented 6 years ago

23 updated bitflags to 1.0, which I believe fixes this issue. Flags are now grouped as constants under a struct, which serves as a namespace. Please feel free to re-open if this isn't what you had in mind.

cmbrandenburg commented 6 years ago

Looks good!