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

Document entire crate #96

Merged
merged 42 commits into from
Jun 10, 2022

Conversation

alice-i-cecile
Copy link
Collaborator

@alice-i-cecile alice-i-cecile commented Jun 8, 2022

Objective

  • docs are great
  • this crate is confusing to use
  • this crate is challenging to contribute to
  • by documenting the crate we'll unearth yet-more tech debt

Fixes #22.

Status

  • deny missing docs
  • document internals
  • document public API
  • document flexbox algorithm parameters in style.rs

@alice-i-cecile
Copy link
Collaborator Author

Help very much wanted here; if you want to add docs before I'm done, please make a PR to this branch!

If you spot something confusing or wrong, leave a comment :)

@alice-i-cecile alice-i-cecile added the documentation Improvements or additions to documentation label Jun 8, 2022
@alice-i-cecile
Copy link
Collaborator Author

Definitely struggling a bit to get the details right for the style.rs file. We'll get there, slowly, but that's the place that needs the most careful review.

Copy link
Collaborator

@TimJentzsch TimJentzsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a first pass on this, mainly for typos.
I also wrote down some possibilities for future improvements in other PRs.

This PR will definitely be an important milestone to make this crate more usable, great effort!

src/node.rs Outdated Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/geometry.rs Show resolved Hide resolved
src/node.rs Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
src/geometry.rs Outdated Show resolved Hide resolved
src/number.rs Show resolved Hide resolved
src/forest.rs Outdated Show resolved Hide resolved
src/forest.rs Outdated Show resolved Hide resolved
src/forest.rs Show resolved Hide resolved
src/style.rs Outdated Show resolved Hide resolved
src/forest.rs Show resolved Hide resolved
src/geometry.rs Show resolved Hide resolved
src/geometry.rs Show resolved Hide resolved
src/geometry.rs Show resolved Hide resolved
src/geometry.rs Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
src/style.rs Outdated Show resolved Hide resolved
@Weibye
Copy link
Collaborator

Weibye commented Jun 9, 2022

So first readthrough was with perhaps too little understanding of flexbox. Then looking at it again for a second go:

When it comes to documentation and naming structs / methods / parameters that relates to flexbox specifically, we should make sure to keep as close as possible with the specs.

  1. This allows users that already know flexbox to know exactly what they are looking at
  2. Allows new users to learn the ins and outs of flexbox instead of just learning how flexbox-in-sprawl-works
  3. Focus our documentation efforts to teach the concepts of flexbox with links to the spec every now and then should some concepts require more details or to encourage further reading.

This would apply for flexbox.rs and style.rs

This might be obvious but I'd thought I'd mention it regardless.

src/style.rs Outdated Show resolved Hide resolved
Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>
@alice-i-cecile
Copy link
Collaborator Author

You all rock; thanks for all the feedback. This collaboration is exactly why I wanted to get a draft PR up ASAP.

alice-i-cecile and others added 3 commits June 9, 2022 12:24
Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>
Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>
@Weibye
Copy link
Collaborator

Weibye commented Jun 9, 2022

My PR into this is now ready for review so please head on over there and speak your mind :) alice-i-cecile#2

It attempts to finish up documentation of style.rs

@alice-i-cecile
Copy link
Collaborator Author

Oh I see! @Weibye we duplicated work; can you add any relevant changes as comments on this PR? Or perhaps rebase your PR?

@Weibye
Copy link
Collaborator

Weibye commented Jun 9, 2022

Oh I see! @Weibye we duplicated work; can you add any relevant changes as comments on this PR? Or perhaps rebase your PR?

On it :)

Copy link
Collaborator

@Weibye Weibye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a complete mess of my PR, but here you have the useful pieces as comments :)

src/style.rs Show resolved Hide resolved
src/style.rs Show resolved Hide resolved
src/style.rs Show resolved Hide resolved
src/style.rs Show resolved Hide resolved
src/style.rs Show resolved Hide resolved
src/style.rs Show resolved Hide resolved
src/style.rs Show resolved Hide resolved
src/style.rs Outdated Show resolved Hide resolved
src/style.rs Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
alice-i-cecile and others added 3 commits June 9, 2022 16:25
Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>
Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>
@alice-i-cecile alice-i-cecile marked this pull request as ready for review June 9, 2022 20:40
@alice-i-cecile alice-i-cecile added this to the Release new crate milestone Jun 9, 2022
Copy link
Collaborator

@Weibye Weibye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📖 I approve this

Copy link
Collaborator

@TimJentzsch TimJentzsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the documentation for style.rs so far, detailed and with links to the specs. Great job!

@@ -8,6 +8,9 @@ use crate::number::Number;
use crate::style::Style;
use crate::sys::{new_vec_with_capacity, ChildrenVec, ParentsVec, Vec};

/// Layout information for a given [`Node`](crate::node::Node)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the smallest nit, but I noticed that you do not include a full stop at the end of the first line of the doc comments, but I did in flexbox.rs. Are there style guidelines/conventions for this in Rust? Do we care enough to make this consistent? (If not it's totally fine to ignore)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care enough right now; if you'd like feel free to put together a style guide PR.

@@ -29,6 +33,8 @@ impl NodeData {
}
}

/// Create the data for a new node
// TODO: why is this different from new_leaf?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn't allow to provide a MeasureFunc, while new_leaf does.
If we want to change something here I think we should also create an issue such that the TODO isn't buried in the code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I think that MeasureFunc is just a bad design, TBH.

pub(crate) struct Forest {
pub(crate) nodes: Vec<NodeData>,
pub(crate) children: Vec<ChildrenVec<NodeId>>,
pub(crate) parents: Vec<ParentsVec<NodeId>>,
}

impl Forest {
pub fn with_capacity(capacity: usize) -> Self {
/// Creates a new [`Forest`] that can store up to `capacity` [`Nodes`](crate::node::Node) before needing to be expanded
pub(crate) fn with_capacity(capacity: usize) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that you changed this from pub to pub(crate), is this a breaking change? To be honest, this crate is the first time I have ever seen pub(crate) so I'm not entirely sure what it does.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not. The type is not public, so the method cannot be used outside the crate anyways.

pub(crate) says "anything within this crate can use this type, but nothing else". pub(super) is the other variant you might run across, which restricts visibility to the parent module.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(pub(crate) would be somewhat similar to internal in C# if you are familiar with that, @TimJentzsch)

src/geometry.rs Outdated Show resolved Hide resolved
src/geometry.rs Outdated Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
@alice-i-cecile
Copy link
Collaborator Author

I'm going to merge this now; feel free to make any further corrections in new PRs :)

@alice-i-cecile alice-i-cecile merged commit de9123e into DioxusLabs:main Jun 10, 2022
jkelleyrtp pushed a commit that referenced this pull request Oct 10, 2022
* Deny missing docs :3

* Module level docs

* Document geometry.rs

* Document layout.rs

* Document prelude.rs

* Document lib.rs

* Document node.rs

* Document number.rs

* Partial docs for style.rs

* Warn that padding broken :(

* Add docs to forest.rs

* Fix typo

Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>

* Fix docs for geometry.rs

* Typo fix

Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>

* Typo fix

Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>

* Revert non-exhaustive annotation

Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>

* Rename unclear method names on Rect

* Clarify wording of mark_dirty field

Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>

* Clarify wording of mark_dirty field

Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>

* Use `parent` as the argument name over `node` in methods on `Forest`

* index -> child_index

* Fix incorrect comment

* More docs for style.rs

* Fix merge error

* Document JustifyContent

* Finish documenting style.rs

* Small improvements to style.rs docs

Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>

* Typo fix

Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>

* Document sys.rs

* Document more of forest.rs

* Docs tweaks

Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>

* Typos

Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>

* Caching notes

* Complete internal documentation

* Cargo fmt

Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>
Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add #![warn(missing_docs)] crate-level rule
4 participants