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

Move the docstrings #34

Merged
merged 3 commits into from
Feb 5, 2022
Merged

Move the docstrings #34

merged 3 commits into from
Feb 5, 2022

Conversation

mcabbott
Copy link
Member

@mcabbott mcabbott commented Jan 31, 2022

The docstrings are much longer than the actual code. I guess I like them long since I extended many of them, but they do get in the way of finding the function body. So this moves them out to the main file, which is otherwise just 3 lines.

No functional change.

@mcabbott
Copy link
Member Author

mcabbott commented Jan 31, 2022

Maybe more controversial, but I'd also like to move code around in the main file. I think it would much easier to read if it was ordered:

  • The basic stuff, up to fmap, 50 lines
  • The extras, like fcollect
  • The vararg extensions
  • FlexibleFunctors

(Not yet pushed.)

@darsnack
Copy link
Member

Good idea. Maybe just put them in a docstrings.jl or interfaces.jl file instead of the main one?

@mcabbott
Copy link
Member Author

mcabbott commented Jan 31, 2022

Ok, pushed. This will trash git blame, but so be it.

Now that I understand it, the 50-line core is actually quite pretty. Maybe I was confused by how much of the auxiliary stuff it was necessary to understand, and by trying to puzzle out docstrings & names for things, not what they do.

@ToucheSir
Copy link
Member

ToucheSir commented Jan 31, 2022

I still stand by #32 (comment), namely that the prettiness comes at a pretty significant cost. That said, this is a genuine QoL improvement for working on the code, as it saves having to jump around too much.

@mcabbott
Copy link
Member Author

mcabbott commented Feb 5, 2022

Good to go?

Putting these in the main file isn't a pattern I've seen, and maybe we will hate it later. But Optimisers.jl does this and it doesn't seem awful. If you don't know the package, then you have to open the file to find out that it has nothing but two includes; and this way, you now also know where the docstrings are. This seems neater to me than needing another top-level file.

Copy link
Member

@ToucheSir ToucheSir left a comment

Choose a reason for hiding this comment

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

Another model I've seen is having the docstrings in external markdown files and attaching them. ConstructionBase does this: https://github.com/JuliaObjects/ConstructionBase.jl/blob/master/src/ConstructionBase.jl#L8

@mcabbott mcabbott merged commit 4a834ce into FluxML:master Feb 5, 2022
@mcabbott mcabbott deleted the movedocs branch February 5, 2022 03:13
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.

3 participants