Skip to content

Latest commit

 

History

History
89 lines (71 loc) · 2.42 KB

File metadata and controls

89 lines (71 loc) · 2.42 KB

Diagnose Circular Includes

Use the backtrace of inclusions to diagnose and correct circular inclusions: that is inclusions that directly or indirectly cause a file to include itself.

Files To Be Included

These files demonstrate nested inclusion, with circular inclusions.

includer_0.md:

@[:markdown](includer_1.md)

includer_1.md:

@[:markdown](includer_2.md)

includer_2.md:

@[:markdown](includer_0.md)

Includer File

This file initiates the nested inclusions.

includer.md:

@[:markdown](includer_0.md)

Include Via markdown_helper

CLI
markdown_helper include --pristine includer.md included.md

(Option --pristine suppresses comment insertion.)

API

include.rb:

require 'markdown_helper'

# Option :pristine suppresses comment insertion.
markdown_helper = MarkdownHelper.new(:pristine => true)
markdown_helper.include('includer.md', 'included.md')

Error and Backtrace

Here's the resulting backtrace of inclusions.

diagnose_circular_includes.err:

C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/markdown_helper-2.4.0/bin/_include: Includes are circular: (MarkdownHelper::CircularIncludeError)
  Backtrace (innermost include first):
    Level 0:
      Includer:
        Location: markdown/use_cases/include/diagnose_circular_includes/includer_2.md:0
        Include pragma: @[:markdown](includer_0.md)
      Includee:
        File path: markdown/use_cases/include/diagnose_circular_includes/includer_0.md
    Level 1:
      Includer:
        Location: markdown/use_cases/include/diagnose_circular_includes/includer_1.md:0
        Include pragma: @[:markdown](includer_2.md)
      Includee:
        File path: markdown/use_cases/include/diagnose_circular_includes/includer_2.md
    Level 2:
      Includer:
        Location: markdown/use_cases/include/diagnose_circular_includes/includer_0.md:0
        Include pragma: @[:markdown](includer_1.md)
      Includee:
        File path: markdown/use_cases/include/diagnose_circular_includes/includer_1.md
    Level 3:
      Includer:
        Location: markdown/use_cases/include/diagnose_circular_includes/includer.md:0
        Include pragma: @[:markdown](includer_0.md)
      Includee:
        File path: markdown/use_cases/include/diagnose_circular_includes/includer_0.md