(self, item)
| 628 | return items_to_process # Iterable for BatchNode |
| 629 | |
| 630 | def exec(self, item): |
| 631 | # This runs for each item prepared above |
| 632 | abstraction_name = item["abstraction_details"][ |
| 633 | "name" |
| 634 | ] # Potentially translated name |
| 635 | abstraction_description = item["abstraction_details"][ |
| 636 | "description" |
| 637 | ] # Potentially translated description |
| 638 | chapter_num = item["chapter_num"] |
| 639 | project_name = item.get("project_name") |
| 640 | language = item.get("language", "english") |
| 641 | use_cache = item.get("use_cache", True) # Read use_cache from item |
| 642 | print(f"Writing chapter {chapter_num} for: {abstraction_name} using LLM...") |
| 643 | |
| 644 | # Prepare file context string from the map |
| 645 | file_context_str = "\n\n".join( |
| 646 | f"--- File: {idx_path.split('# ')[1] if '# ' in idx_path else idx_path} ---\n{content}" |
| 647 | for idx_path, content in item["related_files_content_map"].items() |
| 648 | ) |
| 649 | |
| 650 | # Get summary of chapters written *before* this one |
| 651 | # Use the temporary instance variable |
| 652 | previous_chapters_summary = "\n---\n".join(self.chapters_written_so_far) |
| 653 | |
| 654 | # Add language instruction and context notes only if not English |
| 655 | language_instruction = "" |
| 656 | concept_details_note = "" |
| 657 | structure_note = "" |
| 658 | prev_summary_note = "" |
| 659 | instruction_lang_note = "" |
| 660 | mermaid_lang_note = "" |
| 661 | code_comment_note = "" |
| 662 | link_lang_note = "" |
| 663 | tone_note = "" |
| 664 | if language.lower() != "english": |
| 665 | lang_cap = language.capitalize() |
| 666 | language_instruction = f"IMPORTANT: Write this ENTIRE tutorial chapter in **{lang_cap}**. Some input context (like concept name, description, chapter list, previous summary) might already be in {lang_cap}, but you MUST translate ALL other generated content including explanations, examples, technical terms, and potentially code comments into {lang_cap}. DO NOT use English anywhere except in code syntax, required proper nouns, or when specified. The entire output MUST be in {lang_cap}.\n\n" |
| 667 | concept_details_note = f" (Note: Provided in {lang_cap})" |
| 668 | structure_note = f" (Note: Chapter names might be in {lang_cap})" |
| 669 | prev_summary_note = f" (Note: This summary might be in {lang_cap})" |
| 670 | instruction_lang_note = f" (in {lang_cap})" |
| 671 | mermaid_lang_note = f" (Use {lang_cap} for labels/text if appropriate)" |
| 672 | code_comment_note = f" (Translate to {lang_cap} if possible, otherwise keep minimal English for clarity)" |
| 673 | link_lang_note = ( |
| 674 | f" (Use the {lang_cap} chapter title from the structure above)" |
| 675 | ) |
| 676 | tone_note = f" (appropriate for {lang_cap} readers)" |
| 677 | |
| 678 | prompt = f""" |
| 679 | {language_instruction}Write a very beginner-friendly tutorial chapter (in Markdown format) for the project `{project_name}` about the concept: "{abstraction_name}". This is Chapter {chapter_num}. |
| 680 | |
| 681 | Concept Details{concept_details_note}: |
| 682 | - Name: {abstraction_name} |
| 683 | - Description: |
| 684 | {abstraction_description} |
| 685 | |
| 686 | Complete Tutorial Structure{structure_note}: |
| 687 | {item["full_chapter_listing"]} |
nothing calls this directly
no test coverage detected