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

bug: Not all documentation examples work #78

Closed
1 task done
lewisdenny opened this issue Nov 26, 2024 · 3 comments · Fixed by #86
Closed
1 task done

bug: Not all documentation examples work #78

lewisdenny opened this issue Nov 26, 2024 · 3 comments · Fixed by #86
Assignees
Labels
aspect/documentation 📚 Improvements or additions to documentation domain/obvious 🟩 Represents the "known knowns" issue. It's Obviously good first issue Good for newcomers priority/critical 🟥 Priority 1 - Must be fixed ASAP state/todo 🚀 This is confirmed, will work on soon
Milestone

Comments

@lewisdenny
Copy link

Describe the bug

Hi,

While I was evaluating the use of sprout I noticed some of the documented function examples don't work.

I will focus on cat but the same issue is with all functions that include commas. It wasn't until I read the Go test cases that I understood how to use the functions in a template. I didn't see any other reports of this issue so I assume I'm either misusing or misunderstanding the documentation but I would expect the "Template Example" to work in a template.

Thank you!

To Reproduce

I have a commented go dev link showing the issue: https://go.dev/play/p/LdHAcF0TY33

I will also paste the code here:

package main

import (
	"html/template"
	"log"
	"os"

	"github.com/go-sprout/sprout"
	"github.com/go-sprout/sprout/registry/std"
)

func main() {

	handler := sprout.New()
	handler.AddRegistry(std.NewRegistry())
	funcs := handler.Build()

	// From https://docs.atom.codes/sprout/introduction/getting-started
	tpl1, err := template.New("example").Funcs(funcs).Parse(`{{ hello }}`)
	if err != nil {
		log.Fatal(err)
	}
	tpl1.Execute(os.Stdout, nil)

	// Working version of cat
	tpl2, err := template.New("example").Funcs(funcs).Parse(`{{ cat "Hello" nil 123 true }}`)
	if err != nil {
		log.Fatal(err)
	}
	tpl2.Execute(os.Stdout, nil)

	// From https://docs.atom.codes/sprout/registries/std#cat
	tpl3, err := template.New("example").Funcs(funcs).Parse(`{{ "Hello", nil, 123, true | cat }}`)
	if err != nil {
		log.Fatal(err)
	}
	tpl3.Execute(os.Stdout, nil)

}

Expected behavior

No response

Code Snippet

Version of software

main

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@lewisdenny lewisdenny added state/triage 🚦 Has not been triaged & therefore, not ready for work type/bug 🔥 Something isn't working labels Nov 26, 2024
@42atomys
Copy link
Member

Hi, thanks for reporting that, in documentation , are present and comma don't work on template, good catch 👏

I will do a deep pass on the documentation today !

@42atomys 42atomys added good first issue Good for newcomers priority/critical 🟥 Priority 1 - Must be fixed ASAP state/todo 🚀 This is confirmed, will work on soon domain/obvious 🟩 Represents the "known knowns" issue. It's Obviously aspect/documentation 📚 Improvements or additions to documentation and removed state/triage 🚦 Has not been triaged & therefore, not ready for work labels Nov 26, 2024
@lewisdenny
Copy link
Author

Ah, thank goodness, I thought I was somehow doing something wildly wrong lol.

Let me know if you don't have time for this. I can submit a patch this week.

@42atomys 42atomys removed the type/bug 🔥 Something isn't working label Nov 26, 2024
@42atomys
Copy link
Member

42atomys commented Nov 26, 2024

Thank you for the proposal. If you don’t see a PR related to this issue by the end of the week, feel free to contribute—you are very welcome! 🚀 I'm currently on my open-source time slot so I hope I will have time 🤞

@42atomys 42atomys added this to the v1.0-rc.3 milestone Nov 27, 2024
@42atomys 42atomys linked a pull request Nov 27, 2024 that will close this issue
6 tasks
42atomys added a commit that referenced this issue Dec 1, 2024
## Description
This pull request update all documentation examples and add a tool to
validate each documentation examples on CI to prevent any error on
documentation since now.

## Changes
- Add a tool `task test-doc` to test all documentation examples to
validate the synthax and the output. Act as second e2e testing.
- Validate and update all examples according to the result of the
docvalidator.

## Fixes #78

## Checklist
- [x] I have read the **CONTRIBUTING.md** document.
- [x] My code follows the code style of this project.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] I have updated the documentation accordingly.
- [x] This change requires a change to the documentation on the website.

---------

Signed-off-by: Atomys <contact@atomys.fr>
Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aspect/documentation 📚 Improvements or additions to documentation domain/obvious 🟩 Represents the "known knowns" issue. It's Obviously good first issue Good for newcomers priority/critical 🟥 Priority 1 - Must be fixed ASAP state/todo 🚀 This is confirmed, will work on soon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants