fdoc

subroutinesource_sectionprivate

subroutine source_section(site, id, b, label, heading)

Write the source of entity id, if source is set, from the text of its file.

Arguments

NameTypeIntentAttributesDescription
sitetype(site_t)in

the site

idintegerin

the procedure or type

btype(buffer_t)inout

the HTML

labelcharacter(len=*)in

what opens it

headinglogicalinoptional

whether to start the section, by default true

Calls

Called by

Source

Show the code
subroutine source_section(site, id, b, label, heading)
    type(site_t), intent(in) :: site        !! the site
    integer, intent(in) :: id               !! the procedure or type
    type(buffer_t), intent(inout) :: b      !! the HTML
    character(len=*), intent(in) :: label   !! what opens it
    logical, intent(in), optional :: heading    !! whether to start the section, by default true

    if (.not. wants_source(site, id)) return
    associate (e => site%p%list%box(id)%e)
        if (e%source_first == 0) return
        if (.not. present(heading)) then
            call add(b, '<h2 id="source">Source</h2>'//achar(10))
        else if (heading) then
            call add(b, '<h2 id="source">Source</h2>'//achar(10))
        end if
        call add(b, '<details class="source"><summary>'//label//'</summary>')
        call add(b, '<pre><code>')
        call highlight_fortran(site%p%list%box(e%file)%e%source_text(e%source_first:e%source_last), b, .false.)
        call add(b, '</code></pre></details>'//achar(10))
    end associate
end subroutine source_section