Looks for a valid doctest PS1 prompt in the line given. If one was found, then state for a new doctest code example is returned, along with the code example line.
(original: InputDocstringLine<'src>)
| 879 | /// If one was found, then state for a new doctest code example is |
| 880 | /// returned, along with the code example line. |
| 881 | fn new(original: InputDocstringLine<'src>) -> Option<CodeExampleDoctest<'src>> { |
| 882 | let trim_start = original.line.trim_start(); |
| 883 | // Prompts must be followed by an ASCII space character[1]. |
| 884 | // |
| 885 | // [1]: https://github.com/python/cpython/blob/0ff6368519ed7542ad8b443de01108690102420a/Lib/doctest.py#L809-L812 |
| 886 | let code = trim_start.strip_prefix(">>> ")?; |
| 887 | let indent_len = original |
| 888 | .line |
| 889 | .len() |
| 890 | .checked_sub(trim_start.len()) |
| 891 | .expect("suffix is <= original"); |
| 892 | let lines = vec![CodeExampleLine { original, code }]; |
| 893 | let ps1_indent = &original.line[..indent_len]; |
| 894 | let doctest = CodeExampleDoctest { lines, ps1_indent }; |
| 895 | Some(doctest) |
| 896 | } |
| 897 | |
| 898 | /// Looks for a valid doctest PS2 prompt in the line given. If one is |
| 899 | /// found, it is added to this code example and ownership of the example is |
nothing calls this directly
no test coverage detected