chunklet.code_chunker._code_structure_extractor
Code Structure Extractor
Internal module for extracting code structures from source code. Split from CodeChunker for modularity.
Classes:
-
CodeStructureExtractor–Internal class for extracting structural units from source code.
CodeStructureExtractor
Internal class for extracting structural units from source code.
Methods:
-
extract_code_structure–Preprocess and parse source into individual snippet boxes.
Source code in src/chunklet/code_chunker/_code_structure_extractor.py
extract_code_structure
extract_code_structure(
source: str | Path,
include_comments: bool,
docstring_mode: str,
) -> tuple[list[dict], tuple[int, ...]]
Preprocess and parse source into individual snippet boxes.
This function-first extraction identifies functions as primary units while implicitly handling other structures within the function context.
Parameters:
-
(sourcestr | Path) –Raw code string or Path to source file.
-
(include_commentsbool) –Whether to include comments in output.
-
(docstring_modeLiteral[summary, all, excluded]) –How to handle docstrings.
Returns:
-
tuple[list[dict], tuple[int, ...]]–tuple[list[dict], tuple[int, ...]]: A tuple containing the list of extracted code structure boxes and the line lengths.
Source code in src/chunklet/code_chunker/_code_structure_extractor.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | |