MCPcopy Index your code
hub / github.com/RustPython/RustPython / split_doc

Function split_doc

crates/codegen/src/compile.rs:10491–10508  ·  view source on GitHub ↗
(body: &'a [ast::Stmt], opts: &CompileOpts)

Source from the content-addressed store, hash-verified

10489}
10490
10491fn split_doc<'a>(body: &'a [ast::Stmt], opts: &CompileOpts) -> (Option<String>, &'a [ast::Stmt]) {
10492 if let Some((ast::Stmt::Expr(expr), body_rest)) = body.split_first() {
10493 let doc_comment = match &*expr.value {
10494 ast::Expr::StringLiteral(value) => Some(&value.value),
10495 // f-strings are not allowed in Python doc comments.
10496 ast::Expr::FString(_) => None,
10497 _ => None,
10498 };
10499 if let Some(doc) = doc_comment {
10500 return if opts.optimize < 2 {
10501 (Some(clean_doc(doc.to_str())), body_rest)
10502 } else {
10503 (None, body_rest)
10504 };
10505 }
10506 }
10507 (None, body)
10508}
10509
10510pub fn ruff_int_to_bigint(int: &ast::Int) -> Result<BigInt, CodegenErrorType> {
10511 if let Some(small) = int.as_u64() {

Callers 3

compile_programMethod · 0.85
compile_function_bodyMethod · 0.85
compile_class_bodyMethod · 0.85

Calls 3

clean_docFunction · 0.85
to_strMethod · 0.80
SomeClass · 0.50

Tested by

no test coverage detected