-
Notifications
You must be signed in to change notification settings - Fork 0
13 parse readme to collect test values #15
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
…and output from examples
…ult language from config
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.
tests are failing 💀
|
dans tous les cas je pense qu'on test pas encore assez fort pour pouvoir la mettre sur main |
|
T'inquiètes te freines pas la dessus. Avance sur ton projet sinon tu vas te saouler. Btw: hors du scope de la PR mais tu mets la configuration en |
La config est dans |
On veut pas créer le dossier du probleme en local comme un git clone ? |
J'avais pas vu my bad! |
|
Je te re review sur ca! mais les problèmes sont clairement sur #10 ;') |
…t for multiple inputs
src/readme_parser.rs
Outdated
| raw: readme.to_string(), | ||
| } | ||
| } | ||
| pub fn parse(&self) -> Result<ProblemTestData, Box<dyn std::error::Error>> { |
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.
J'ai enfin lu le guide sur l'error handling en Rust dont je te parlais et de ce que je lisais il faudrait éviter les Box<dyn Error> comme ça.
Ca rend leur management programmatique difficile (comme un conditionel sur le type d'erreur rendu), c'est surtout utile quand tu sais que tu veux output une erreur qui n'est que destiné qu'à être logger dans le terminal (donc plutôt les erreurs qui sont exposées au end-user).
Dans le cas d'une méthode que tu utilises aux seins de ton programme comme ça et qui pourrait nécessiter d'être intéragit avec c'est mieux de déclarer des erreurs de manières static. C'est généralement assez long mais tu peux vraiment vivifier la chose avec thiserror.
Je vois si je peux pas te faire ça à la suite dans un commit de la PR.
…error in LeetcodeReadmeParser signature functions
guilhem-sante
left a comment
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.
J'approuve la PR du coup rien à dire sur le reste. Je te mets en review de la PR pour que tu checks le changement que je t'ai suggérer du coup.
Aussi, après mon changement j'ai voulu checker ta suite de test mais 1 test échouait et en le regardant j'ai supposé que c'était dû à mon absence de token leetcode. Donc je pense que c'est bon mais revérfie si tu peux pour être sûr.
| #[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)] | ||
| pub enum LeetcodeReadmeParserError { | ||
| #[error("can't parse empty readme")] | ||
| EmptyReadme, | ||
| } | ||
|
|
||
| impl LeetcodeReadmeParser { | ||
| pub fn new(readme: &str) -> Self { | ||
| LeetcodeReadmeParser { | ||
| raw: readme.to_string(), | ||
| } | ||
| } | ||
|
|
||
| pub fn parse(&self) -> Result<ProblemTestData, LeetcodeReadmeParserError> { | ||
| if self.raw.is_empty() { | ||
| return Err(LeetcodeReadmeParserError::EmptyReadme); | ||
| } | ||
| Ok(ProblemTestData { | ||
| example_count: self.count_examples(), | ||
| inputs: self.extract_inputs(), | ||
| outputs: self.extract_outputs(), | ||
| }) | ||
| } |
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.
Voilà, ça donnerait un truc comme ça du coup. Avec une erreur définie statiquement.
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.
Archi chaud!
Merci mec c'est super cool!
En revanche t'as commit 10 autres fichiers pour du styling, c'est accidentel?
Bon je peux pas te mettre en review de ta propre PR mais je te laisse me donner ton avis sur la question des erreurs en tout cas. |
Bah ecoute je viens de review, et c'est super quali merci beaucoup! |
This pull request introduces several significant changes to the
leetcode-cliproject, focusing on adding a new feature for parsing problem README files, improving API handling, and enhancing error handling and flexibility. The changes also include updates to dependencies and tests.New Feature: README Parsing
readme_parserto parse problem README files, extracting example counts, inputs, and outputs using regular expressions. (src/readme_parser.rs, src/readme_parser.rsR1-R61)readme_parsermodule to validate its functionality with sample README files. (tests/readme_parser_tests.rs, tests/readme_parser_tests.rsR1-R116)tests/data/221.md, [1];tests/data/3467.md, [2];tests/data/392.md, [3]API and Command Enhancements
LeetcodeApiRunner::newmethod to take a reference toRuntimeConfigSetupinstead of consuming it, improving memory efficiency. (src/leetcode_api_runner.rs, src/leetcode_api_runner.rsL26-R29)mainfunction to reflect the changes inLeetcodeApiRunnerand to handle the default programming language when none is provided. (src/main.rs, [1] [2]languagefield in theCommandsenum to be anOption<String>to allow for optional language input. (src/cli.rs, src/cli.rsL23-R23)Error Handling Improvements
parse_programming_languagefunction to return aResultinstead of panicking on unsupported languages, improving error handling. (src/utils.rs, src/utils.rsL37-R65)Dependency and Configuration Updates
regexcrate as a new dependency to support thereadme_parsermodule. (Cargo.toml, Cargo.tomlR38)Cargo.tomlfromleetcode_clitoleetcode-cli. (Cargo.toml, Cargo.tomlL17-R17)These changes collectively enhance the functionality, robustness, and maintainability of the
leetcode-cliproject.