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

docs: Create JSON helper for template funcs #3418

Closed
bep opened this issue May 1, 2017 · 8 comments · Fixed by #3420
Closed

docs: Create JSON helper for template funcs #3418

bep opened this issue May 1, 2017 · 8 comments · Fixed by #3420

Comments

@bep
Copy link
Member

bep commented May 1, 2017

See #3417

The data is (almost) complete and ready to dump to JSON.

Pseudo-data:

namespace:
   collections
   funcs:
      After
        description: "After returns all the items after the first N in a rangeable list."
        aliases: ["after"]
        examples: [["in", "expected"]]

Most of the stuff above is straight forward; to get the description we would have to run the code through the GoDoc parser, which is doable and a nice-to-have.

The big motivations for the above is:

  • To reduce maintenance cost.
  • To make sure docs is correct and up-to date
  • To make sure the examples are correct (we run them as part of the test suite).

Since we can not create content pages from data, I assume a shortcode could include this in the content pages.

/cc @moorereason @rdwatters

@bep bep self-assigned this May 1, 2017
@bep bep added this to the v0.21 milestone May 1, 2017
@rdwatters
Copy link
Contributor

I could see something like this making doc maintenance much easier, so thank you.

To further my understanding, please:

I know your example is pseudocode, but I'm not sure I follow what examples: [["in", "expected"]] means. Would you mind expanding?

When you talk about creating a shortcode, are you thinking similar to the table shortcode you created with custom outputs? If we are keeping a 1-md-file-per-func model (better for SEO), maybe even a smart partial would work. Then an editor doesn't have to worry about including the shortcode within {{.Content}}...

@bep
Copy link
Member Author

bep commented May 1, 2017

Partial would also of course work fine -- the examples will be clear once finished.

@bep
Copy link
Member Author

bep commented May 1, 2017

@rdwatters look at https://github.com/bep/hugo/blob/e0a2b8a8ac05eed2e853e8ad2b6b1e3ba049c705/docs/data/docs.json

Scroll to bottom.

I notice I have to do a job with the JSON to make it more "lookup friendly".

bep added a commit to bep/hugo that referenced this issue May 1, 2017
And fix some other minor related issues.

Updates gohugoio#3418
@bep bep closed this as completed in #3420 May 1, 2017
bep added a commit that referenced this issue May 1, 2017
And fix some other minor related issues.

Updates #3418
@bep bep reopened this May 1, 2017
@rdwatters
Copy link
Contributor

rdwatters commented May 1, 2017

Ah, got it. Thanks for the clarification.

For context, here is the new functions archetype.

https://github.com/rdwatters/hugo-docs-concept/blob/master/themes/hugo-docs-concept/archetypes/functions.md

Seems like a lot of tedious work has already been undertaken by you and @moorereason, but do you think there are maintenance benefits to adding properties such as deprecated, hugoversion, and especially the signature array (see rdwatters/hugo-docs-concept#31)?

Just a thought. I'm not suggesting we automate all of it. 😄

@bep
Copy link
Member Author

bep commented May 1, 2017

The info in that JSON (description coming soon) is what we know. Nothing else CAN be generated. (I could generate the signature, but it is all interface{} values, which does not make sense without manual interpretation.

What I do suggest, however:

  • Drop the deprecated and signature and just put that info into method description (in JSON)
  • Not sure what Hugo version is all about.

But, we should do this in some documentation related issue.

@rdwatters
Copy link
Contributor

But, we should do this in some documentation related issue.

Works for me.

Not sure what Hugo version is all about.

I'm assuming my thoughts were related to versioning of docs, deprecations, etc. I'm not wedded to it if it can be automated 😄 Cheers.

@bep
Copy link
Member Author

bep commented May 1, 2017

Yes, I see the value in "does this work in my Hugo?", but let us discuss that somewhere else -- that can not be "auto generated" (in an easy way).

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants