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

Create code samples from code, a.k.a. code excerpts #358

Merged
merged 27 commits into from
Nov 22, 2023
Merged

Conversation

ahmednfwela
Copy link
Collaborator

@ahmednfwela ahmednfwela commented Sep 21, 2023

Pull Request

What does this PR do?

This PR completely automates updating the code samples file .code-samples.meilisearch.yaml
it creates a new PRIVATE tool that does 2 things

  1. updates the sample file from source code (run by contributors)
  2. check if the sample file is up to date with source code (run in CI)

the private tool checks dart files in lib/ and test/ directory for lines that follow this pattern:

// #docregion key
anything()
// #enddocregion

where key is a key in .code-samples.meilisearch.yaml

This run shows CI fail in action, due to format mismatch for key search_parameter_guide_show_ranking_score_1 between code file and yaml file.

This commit f9109a0 shows how to fix the failed run, by running dart run ./tool/bin/meili.dart update-samples in the root directory of the repo.

this should simplify adding samples, and avoid issues like #357


Update

I have also added functionality to detect missing and useless keys, see this failing run for example: https://github.com/meilisearch/meilisearch-dart/actions/runs/6262599763/job/17005143489?pr=358#step:4:159

PR checklist

WIP

  • remove unnecessary indentations from code.
    Please check if your PR fulfills the following requirements:
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

@ahmednfwela ahmednfwela added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Sep 21, 2023
@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (bf1f5d4) 82.03% compared to head (228a95b) 82.03%.
Report is 28 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #358   +/-   ##
=======================================
  Coverage   82.03%   82.03%           
=======================================
  Files          57       57           
  Lines        1353     1353           
=======================================
  Hits         1110     1110           
  Misses        243      243           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ahmednfwela
Copy link
Collaborator Author

@curquiza @brunoocasali the internal tool still needs more work, but I want your opinion if you agree with this approach.

brunoocasali
brunoocasali previously approved these changes Nov 22, 2023
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very sorry @ahmednfwela for taking so long here 😢

That's very cool @ahmednfwela let's go for it! Do you think it would be possible to do that with other languages but using the same tooling?

Also, can you update the CONTRIBUTING?

@ahmednfwela
Copy link
Collaborator Author

@brunoocasali Yes we can definitely do that with any language that supports comments, the tooling is language agnostic.

we can ship the tooling as an exe file that's built from a different repository

brunoocasali
brunoocasali previously approved these changes Nov 22, 2023
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ahmednfwela
Copy link
Collaborator Author

bors merge

Copy link
Contributor

meili-bors bot commented Nov 22, 2023

Build succeeded:

@ahmednfwela ahmednfwela merged commit ef898fa into main Nov 22, 2023
8 checks passed
@ahmednfwela ahmednfwela deleted the code-excerpts branch November 22, 2023 20:30
meili-bors bot added a commit that referenced this pull request Mar 11, 2024
376: Update version for the next release (v0.16.0) r=curquiza a=meili-bot

_This PR is auto-generated._

The automated script updates the version of meilisearch-dart to a new version: "v0.16.0"

---

Parr of the work of #375 

---

This version introduces features released on Meilisearch v1.7.0 🎉
Check out the changelog of [Meilisearch v1.7.0](https://github.com/meilisearch/meilisearch/releases/tag/v1.7.0) for more information on the changes. 

 ## ⚠️ Breaking changes

* `scoreDetails` feature is not experimental anymore. You can directly use `showRankingScoreDetails` during a search without activating the experimental feature 🎉

## 🚀 Enhancements

* Add text separators (#379) ahmednfwela

## ⚙️ Maintenance/misc

* Create code samples from code, a.k.a. code excerpts (#358) ahmednfwela
* Update dart version and checkout (#367) brunoocasali
* fix ci steps (#378) ahmednfwela
* docs: Add readme section about dio (#380) ahmednfwela


Co-authored-by: meili-bot <[email protected]>
Co-authored-by: Ahmed Fwela <[email protected]>
Co-authored-by: Clémentine U. - curqui <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Anything related to maintenance (CI, tests, refactoring...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants