-
Notifications
You must be signed in to change notification settings - Fork 14
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
SDKs Documentation in API References - MVP #3
Comments
|
In my opinion, the proposition made by @bidoubiwa makes sense, thanks! First of all, this will only work if it is really easy to identify which is the file example that you have to modify when you change a method in a SDK. I am not sure about some details: 1. CLI
2. Compiling examples
3. Two different files, one for the example,one for the response
|
What we are trying to achieve:
Real-time update: Since VuePress is built as a static website, we may not be able to use Vue as a cliend-site rendering which is sad because we could have imagined the Vue app to get on client-side the examples in each SDK GitHub repository. We should have a VuePress component that will get the SDKs' examples on each GitHub repository at build time. If no example is available, the component won't build the tab associated with that language. We can have one or multiple file in each repository that should be hidden ./meilisearch-php
| scripts/
| src/
| tests/
| .documentation-samples #hidden file or directory
| ... This way the VuePress component can get each sdks sample based on this url:
Documentation sampleHow to format this document or this repository?I would prefer a simple document to ease the work on the component side and because we only have around 40 examples to write down for each sdk. This is something that could evolve later ofc, but we can start with a simple file. E.g. using YAML for examples in Ruby: ./documentation-samples
---
create-your-index: |-
require 'meilisearch'
client = MeiliSearch::Client.new('http://127.0.0.1:7700')
index = client.create_index('movies')
add-documents: |-
require 'json'
movies_json = File.read('movies.json')
movies = JSON.parse(movies_json)
index.add_documents(movies) What format?
ConclusionWe may not have something very modular here but I think this solution would provide us with a working solution ASAP since we only have to agree on a format and write the VuePress component that will get each sample based on convention we can agree on. We are avoiding here CLIs tools or github-action or even transpilation scripts ^^ |
Why not using markdown as a format?
|
Markdown is a markup language, not a data-serialization format so we won't have slug or ids natively supported but we can work around something for sure |
I really like your idea @tpayet ! The format/language discussion is indeed an important one for this implementation. Doing our own format will for sure create a lot of work not only now, but also in the future, as it evolves. YAML and MarkDown (with a slug/id workarround) seem like the most promising solutions for that! In fact, the md solution is great because it would be easy for the developer to rely on other tools for highligthing etc, and be sure about the result he will have in the published documentation. |
After reading through all of your suggestions and after a talk with @curquiza this is the final proposition Foreword: We decided to go for stripes solution by not adding the Steps required
In order to get everyone's votes, let me propose the following template
Feel free to add your suggestions and/or additional information. I can always edit this post. Template formatThe templates are generated based on a file that contains all places in the documentation that requires an example. Solution 1: one file solutionYAML file generated this way: ./documentation-samples import_sdk_1: |-
get_index_request_1: |-
get_indexes_request_1: |-
create_index_request_1: |-
delete_index_request_1: |-
get_document_request_1: |-
... How it is expected to work ? Yaml accepts multi-line "strings", nevertheless, it is expected that each sample has the appropriate number of tabs to be valid YAML. (some random example of single, empty and multiline examples) import_sdk_1: |-
import MeiliSearch from MeiliSearch
get_index_request_1: |-
require 'meilisearch'
client = MeiliSearch::Client.new('http://127.0.0.1:7700')
index = client.create_index('movies')
get_indexes_request_1: |-
create_index_request_1: |-
client.createIndex("movies") This template should be added at the root of each SDK
Solution 2: multifile solutionIn a folder called
Each file is empty and expect the sample in the appropriate language. How it is expected to work ?
Samples formatHow do we right examples for the documentation ? Solution 1: no-complexity no-indexclient.getIndex('movies').addDocuments(docs) Solution 2: no-complexity indexindex.addDocuments(docs) Solution 3: some-complexity indexjson_file = open('movies.json')
movies = json.load(json_file)
index.add_documents(movies) Solution 4: all-complexity indexindex = client.get_index('movies')
json_file = open('movies.json')
movies = json.load(json_file)
index.add_documents(movies) Imports can be added to any of the above suggestion, feel free to precise your vote with imports. require 'meilisearch'
client = MeiliSearch::Client.new('http://127.0.0.1:7700')
index = client.create_index('movies') Get the templateThe first step is to get a template in each SDK that the contributor will use to complete all code samples. This make it easier for him because it does not require to search it up, and this gives us the possibility to add human readable slugs. Solution 1: Documentation scriptGenerate the file(s) from the documentation Solution 2: HTTP requestFrom a HTTP request Fetch the samplesSolution 1: server-side on buildServer side on build. While the documentation is building, from a list of SDK's, it will fetch all samples files (multifile or singlefile) from every given repository. This means, that the changes made to the different samples files will only be published once the documentation is built and published again. A Possible solution to that would be to have a scheduler CI that checks on changes every now and then (2 hours suggested by clementine). Solution 2: Client side on loadIt is in fact possible to gather all the code examples at runtime. Using the state library Display the samplesOnly one solution here : Solution 1: Vue componentCommon to both solutions: The Based on the repository from which each sample originate the code will be displayed this way:
Unless specified otherwise by the configuration file in the documentation that can overwrite it with another present (example bash instead of the given language). |
Final decision for MVP (team meeting):
Edit from Clementine:
Not in the MVP if I'm not wrong. We will re-run the CI for the build if needed. But, yes, it will be in server side later as a future improvement. |
The MVP was merged in the docs!! -> meilisearch/documentation#356 I'm proud to close this issue 😌 |
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.
Related issue
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:
Steps
Bonus:
Bonus ++:
The text was updated successfully, but these errors were encountered: