-
Notifications
You must be signed in to change notification settings - Fork 21
guides: add new generator #3837
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
Conversation
✔️ Code generated!
📊 Benchmark resultsBenchmarks performed on the method using a mock server, the results might not reflect the real-world performance.
|
"prout": { | ||
"method": "prout", | ||
"parameters": { | ||
"indexName": "cts_e2e_saveObjects_${{language}}", | ||
"objects": [ | ||
{ | ||
"objectID": "1", | ||
"name": "Adam" | ||
}, | ||
{ | ||
"objectID": "2", | ||
"name": "Benoit" | ||
} | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've rarely seen a pr this perfect
of course it's perfect |
5ff472f
to
5929d04
Compare
generators/src/main/java/com/algolia/codegen/cts/manager/SwiftCTSManager.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wonderful
Co-authored-by: Pierre Millot <[email protected]> Co-authored-by: shortcuts <[email protected]>
🧭 What and Why
🎟 JIRA Ticket: https://algolia.atlassian.net/browse/DI-2974 https://algolia.atlassian.net/browse/DI-2975 https://algolia.atlassian.net/browse/DI-2976
Changes included:
supersede #3836
this PR adds a new generator in order to be able to generate guides.
Context
The onboarding team creates guides using the API client plus some other external libraries (e.g. fetch) in order to showcase how to push data to Algolia.
Today they only provide snippets for JavaScript, and it requires us manual intervention, manual testing, linting etc.
They'd like to be able to keep their guides up to dates with our API clients, and at some point, provide guides for more languages than just JavaScript.
In their initial RFC, they were proposing to create a CI that does exactly what we do, so in order to platformize a bit more our repository, @shortcuts suggested to leverage our tooling to generate their guides
How does it work
This PR is not complete, we are missing a few things that will be tackled in https://algolia.atlassian.net/browse/DI-2984 and https://algolia.atlassian.net/browse/DI-2985 but the goal is simple
From a mustache file (located in
templates/${language}/guides/${api}
), and a guide definition (located intests/CTS/guides/${api}
), generate a fully working guide, self contained file, for every available clients.Example
I create my
templates/go/guides/search/saveObjectsWithSofa.mustache
file:The dynamic snippet template will read the
tests/CTS/guides/search/snippets.json
:The key that has been passed to the dynamic template (
saveObjectsWithSofa
) is there and contains the method to find in the spec, and the parameters to feed it. TheparametersWithDataType
logic is the same as for the tests and snippets generator, as well as for the mustaches file.You can now write for example
templates/php/guides/search/saveObjectsWithSofa.mustache
, the process will be the same.Other changes
We don't need to have the snippets folder/files anymore, just the JSON file output for the documentation. So we removed it from the repo, and ignored it, it now only lives on the CI