fdoc

subroutineentity_urlrecursive

recursive subroutine entity_url(list, id, url)

The URL of an entity relative to the root of the site, or ''.

Arguments

NameTypeIntentAttributesDescription
listtype(entity_list_t)in

the entities

idintegerin

the entity

urlcharacter(len=:)outallocatable

the URL

Calls

Source

Show the code
recursive subroutine entity_url(list, id, url)
    type(entity_list_t), intent(in) :: list             !! the entities
    integer, intent(in) :: id                           !! the entity
    character(len=:), allocatable, intent(out) :: url   !! the URL
    character(len=:), allocatable :: word, name, quoted
    integer :: at
    logical :: has_page

    associate (e => list%box(id)%e)
        if (allocated(e%external_url)) then
            url = e%external_url
            return
        end if
        has_page = .false.
        select case (e%kind)
        case (E_FILE, E_MODULE, E_SUBMODULE, E_PROGRAM, E_BLOCKDATA, E_NAMELIST)
            has_page = .true.
        case (E_TYPE, E_INTERFACE, E_SUBROUTINE, E_FUNCTION, E_MODPROC)
            has_page = e%iface /= IFACE_NONE
            if (e%parent > 0) then
                select case (list%box(e%parent)%e%kind)
                case (E_FILE, E_MODULE, E_SUBMODULE, E_PROGRAM, E_BLOCKDATA)
                    has_page = .true.
                end select
            end if
        end select
        call object_word(e, word)
        call page_name(e%name, name)
        if (has_page) then
            if (e%kind == E_SUBMODULE) word = 'module'
            if (allocated(e%page)) then
                url = word//'/'//e%page//'.html'
            else
                url = word//'/'//name//'.html'
            end if
            return
        end if
        url = ''
        if (e%parent == 0) return
        select case (e%kind)
        case (E_BOUNDPROC, E_COMMON, E_VARIABLE, E_ENUM, E_FINAL, E_SUBROUTINE, E_FUNCTION)
            call entity_url(list, e%parent, url)
            if (len(url) == 0) return
            at = index(url, '#')
            if (at > 0) url = url(:at - 1)
            call url_quote(name, quoted)
            url = url//'#'//word//'-'//quoted
        end select
    end associate
end subroutine entity_url

Graphs

Calls

Called by