-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
content: Describe result of delimiting an empty collection #2906
Comments
I really don't want to go down this path, because the next ask is, "We need to document what happens with collections.Last with an empty collection." Etc. Etc. |
There's nothing wrong with clearly stating the result of a function call. The user of a function should know what he's going to get. Imho the point is to identify the parts where it is necessary and how much details need to be given towards the audience - keep in mind that many users do not have a programming background. Delimiting for me means I have something to delimit, so the it's quite obvious that if there's nothing an empty string is returned. so it's just one sentence like "Delimiting an empty slice or map will return an empty string". That won't hurt and make it all clear. Just like that one "The delimit function sorts maps by key, returning the values". 👍 see |
Maybe I'm just being disagreeable, but the ability to delimit a map was surprising to me, as is its sorting when you do so, unless you think about it and understand that Go maps are unordered. To me, what happens with I've been trying, with feedback from the community, to eliminate inconsistencies in the documentation for a long time. If we're going to add this to the If someone want to go through all the functions and methods and develop a list of where we should do this, I'm open to it as long as I don't have to do the work. |
@jmooring Can you be specific? |
@willfaught I cannot be specific because I don't know, which is why I wrote:
|
you already follow a rolling release with the docs, so one improvement on a one page is an improvement (ok maybe in 97% of the cases). It helps to identify similar conditions for readers and authors and maybe next time one reads another page he misses that and just adds...
But it does not always be the one big shot thing. For that one I would just pick the place that seems to fit best, add it and see what happens. I could elaborate on a proposal. Ofc only if you are willing to go that way cause all over it will put load on you. TL;TR; and definitely not part for an issue discussion Indeed, direct delimit is surprising usually you have to do
Not only trying you did a very good job. I'm here for almost a year (fresher ;-) but I've seen a lot of improvements on the docs. and I blame that mostly up on you. Thx for spending the effort here. For me you have a quite cool mixture of technical part and examples. The problem with documentation is always the target group. Especially becoming more and more popular, more and more users lack the knowledge about internals. So on the mid/long run your target group will (and maybe already is) less technical. For the Interface documentation I agree with the effort and time... documentation managing is a mess. that all said. I appreciate our work so much 💯 |
@jmooring I was referring to:
What do you mean by other places? Other functions that return strings? Other functions that operate on slices? What do you mean by consistent formatting? Do you mean consistent wording? Do you mean ensuring that the wording appears in its own paragraph, as opposed to adding it as a sentence of an existing paragraph? Why isn't adding "For an empty slice, the empty string is returned." as a new paragraph to the delimit doc sufficient concretely? Give a single example, please. I have no idea what you mean, so you've erected a barrier to closing this issue that isn't actionable. It seems to me that if someone wants to make other places in the doc consistent with the delimit doc after this is resolved, they are more than welcome to, and can do it in a separate issue/PR, especially if all they have is a vague sense that "something" has to be "done". |
Is there anything in this list that you find surprising?
|
Should it be []any{[]any(nil)}?
Can funcs like this return []any(nil) instead?
I would expect an error, since both (max (slice)) and (max (slice 0 -1 -2 -3)) are 0 and you need to be able to distinguish between the cases. There has to be at least one arg. If there's one arg, the result is the arg. Similar issue with math.Product/Sum. The rest make sense to me! Noticed some things while researching this: https://gohugo.io/functions/collections/querify/:
This might be clearer at a glance: collections.Querify [KEY VALUE]... https://gohugo.io/functions/collections/after/:
I think INDEX should be COUNT or LENGTH? https://gohugo.io/functions/collections/symdiff/:
Seems odd to show pipe syntax. When searching for "math.max", math.Max is the 5th result: https://gohugo.io/functions/math/max/:
greater of all numbers -> greatest number? Nice job with the doc redesign, by the way! |
would have expected that to fail -> so the "." is unset which makes add failing - looks like the implemention check for empty array
by heart I would have expected that to fail (or return nil). These two are equivalents, both try to return the first element of the array, a typical out of bounds in other languages. - but I like that behavior which is like natural speech. There's a subtle difference in treating the number in index and first/after/last.
just the type why isn't that return type just a MAP (for the users) - is there any difference in methods? (didn't scan docs)
arguments FIRST INCREMENT LAST are implicit INTs so wrong type you may also use
I would keep the behavior: If I never had any money, the max and min I had would be 0 and leave the empty slice test to the user.
I think it's common understanding that these do not fail but return the expected type of value. at least in a requirement spec that would be one point to specify - ** while writing this** .... if we treat Examples as part of the SPEC/Documentation this all could be handled with examples for the edge cases. |
So, between the two of you, can you come up with a document (to be split into pieces later) that provides an example for each edge case for each of the functions that require it? No text—just examples. I'm thinking we add something like this to the bottom of the relevant function pages. For example, for the delimit page:
This isn't about making changes to how the functions behave, but instead to document existing behavior, regardless of whether you think it's wrong. |
I think the doc should explicitly specify this in words. To illustrate part or all of the specification with examples is error-prone and verbose. Examples should supplement specifications, especially for things that are complicated to explain in text, or things that have complex implications. Go doc successfully specifies built-in template funcs with just text. I don't mind doing that work if I have assurance that it will be merged. |
I prepared a document to show how it could like for the discussed functions considering some findings while preparing: My suggestion would be to have the following after the starting a Usage section which tells how the function is to be used. No complex stuff here like combining the function with otheres (except where neccessary - one must have a slice to explain delimit.
after that zero an Examples section which describes some extended or complex use cases. each with a heading or some natural text and then the code some with notes at the right places to highlight additional important stuff or info. That way we have a clear separation between
If you put that in /content/en/functions and call some remarks for stuff found in these function pages
I also here and there found small typos, missing blanks etc also when normally using docs - would it be ok, to just file a PR for such things for master or do you want a branch, an issue or both? |
Having consistent level 2 headings ("Usage" and "Examples") on each function and method page would be great, and your explanation makes sense to me. I presume you would include the edge/unexpected cases at the end of the input -> output examples within the Usage section. In some cases we may require additional level 2 headings, but I think those two are a good baseline. Notes
ImportantI have a branch in progress with a huge change set (affects > 500 files). It would be best to hold off on any PR's until this is merged, which should happen within the next week. ImplementationI suggest we start with a handful of pages in one section to work out the kinks, if any. SummaryMany of these pages were written years ago, and while I have attempted to add some consistency, getting them factually correct has been the priority:
Any help to provide consistency will be much appreciated. |
With the previous theme the "On This Page" sidebar was configured for level 2 headings only, so sometimes the information was structured accordingly, using level 3 heading sparingly. That's no longer the case. The "On This Page" sidebar presents
One example of this is the
Another example is Yeah, you could place Options as a level 3 heading under Usage, but 1 subheading is goofy looking and doesn't make organizational sense to me. We might also consider 3 baseline level 2 headings:
And some pages require a top level "Methods" section as well (e.g, Something to think about. |
I would tend to not call that edgs/unexpected. It's a clear definition what it does and what it returns. Using examples and text here makes it easier for non-technical users to understand. For technical users that will help to get the points that might be different with their experience (other languages...) and ofc there's an order from common to special usages/returns with the common cases first. Red numbers:
yellowSection 3 fully describes what you can expect and how it behaves. No complex scenarios here. Each entry either tells
=> now all is described to use the function Section 4: visualizes some common paradigms the same way (5+6) little more complex => provides hints or common patterns for utilizing Section 5: would give a complete elaborated example with
=> for deeper understanding tbc need a break |
Maybe just take these as a startup and see how far we get.
sometimes the text at the top of the article is even more brief that the one from the description. Just stumbled over simetimes it starts with an example directly and sometimes not. With the new setup,
definitely agreed
right approach for me
For sure I will. |
haven't had a look at a function having examples yet but right off the bat I would not move it below Usage. quick check currently the functions section has > 275 pages, but just two have Arguments headings (Where and transform.Highlight) mmh think more have some arguments/options.... I'll take these two and elaborate
short: yes, as of now it is the case
long: I would keep them but right off the bat this seems to be related to the docs and Object Model organization. We have Methods but no explicit Objects or Types;-). And some kind of namespace for functions which effectively is hidden for a lot using aliases. Sometimes the underlaying Go stuff shines through (maps.Scratch, interfaces) The outer view: Having a method section below a function does not seem right to me... nothing I would like to touch - looks like complete new topic. |
https://gohugo.io/functions/collections/delimit/:
Presumably it returns the empty string, but it should say that.
The text was updated successfully, but these errors were encountered: