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

Add comments for html5ever/examples #506

Merged
merged 1 commit into from Apr 3, 2024

Conversation

organic1337
Copy link
Contributor

My first PR here :)

I decided I wanted to contribute to this cool project, and when I started learning about it, I headed over to the examples directory, and it was quite hard for me to understand what I was reading because it lacked some comments.

Someone already opened an issue about it.

Changes

  • Add comments to the main function in each example with a short description of what the code does.
  • Added comments for structs and traits implemented in the examples.
  • Move the main function in arena.rs example to the end of the file (to match the other examples)

Copy link
Member

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

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

I could see us adding comments on particularly tricky parts of the code and maybe succinct descriptions of what the examples do, but I don't think we need comments of the type:

// Create a new arena
let arena = typed_arena::Arena::new();

which simply repeat what the code itself is saying. In general, clearer code and better variables names are preferred to comments for me.

Quick question though: Were these comments generated with a large language model like ChatGPT? I don't think we want AI generated code or comments at the moment. Thanks for understanding.

@organic1337
Copy link
Contributor Author

Hi Martin thx for the comment.

I've removed some comments which just repeat simple code (like the arena example)

There's no doubt that good naming and self-explanatory code are much better than comments. Though in the case of code example, comments can make the newbie developers' life easier.

I wanted to step into this project in order to contribute it in some way, and the examples/ folder was the first place I visited, and tbh, I did not understand much just from reading it... I had to dig deeper in the library to fully understand what's going on there and understand the terminology.

And no, non of these comments were generated by any kind of LLM, as I mentioned before I'm interested to help develop this project so I wanted to actually learn how it works.

Copy link
Member

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

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

Thanks for the clarification and the contribution.

Copy link
Contributor

@rillian rillian left a comment

Choose a reason for hiding this comment

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

Seems like a useful improvement to me.

@rillian
Copy link
Contributor

rillian commented Apr 3, 2024

@organic1337 this needs rebasing past #520 if you're still interested in working on it.

@mrobinson mrobinson enabled auto-merge April 3, 2024 17:15
@mrobinson mrobinson added this pull request to the merge queue Apr 3, 2024
Merged via the queue into servo:main with commit 5cc0951 Apr 3, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants