Closed
Description
Currently, there is no SDK documentation except the READMEs and the Getting Started in the docs.
But, in this part of the docs, the code is hard-written: the code snippets are not automatically generated. If the SDK methods change, the documentation needs to be changed too.
We should find a way to link the docs repository and each of SDKs.
In one PR, the SDK maintainers should be able to change the code of the SDK and the docs at the same time.
With this kind of solution, it would be able to add more code snippets in API References.
How?
A "simple" solution would be to add a template file in each SDK that the documentation would be able to read and then generate code snippets according to this file.
Example of a template file:
###
# guides/introduction/quick_start_guide.html#create-your-index
$ gem install meilisearch
---
require 'meilisearch'
client = MeiliSearch::Client.new('http://127.0.0.1:7700')
index = client.create_index('movies')
###
###
# guides/introduction/quick_start_guide.html#add-documents
require 'json'
movies_json = File.read('movies.json')
movies = JSON.parse(movies_json)
index.add_documents(movies)
###
###
# guides/introduction/quick_start_guide.html#search
index.search('botman')
###
Steps
- Find a great syntax for the template files: thinking about the delimiters, the "title" of the code snippet...
- In the docs part: create a parser able to read the template and then, generate the code snippets => most of the work is in the docs part.
- Find a way to regenerate the docs if a template changes (there is scheduler with GHA to check them on regular bases)
- The docs should provide a script that generates an empty template.
Bonus:
- If the template changes, a bot should create a PR (or at least an issue) to change the current template for each SDK repository.
Bonus ++:
- Find a way to test the lines of code in the template files, to be sure that we provide good examples in the docs.