fdoc

subroutinefinish_settings

subroutine finish_settings(s, directory, stat, errmsg)

Make paths absolute and format dates, after all settings are applied.

Arguments

NameTypeIntentAttributesDescription
stype(settings_t)inout

the settings

directorycharacter(len=*)in

the project's directory

statintegerout

nonzero on failure

errmsgcharacter(len=:)outallocatable

what is wrong

Calls

Source

Show the code
subroutine finish_settings(s, directory, stat, errmsg)
    type(settings_t), intent(inout) :: s                !! the settings
    character(len=*), intent(in) :: directory           !! the project's directory
    integer, intent(out) :: stat                        !! nonzero on failure
    character(len=:), allocatable, intent(out) :: errmsg  !! what is wrong
    integer :: k

    stat = 0
    s%directory = resolve_path(directory, '.')
    if (s%md_base_dir == '.') s%md_base_dir = s%directory
    call normalise(s%css)
    call normalise(s%favicon)
    call normalise(s%graph_dir)
    call normalise(s%logo)
    call normalise(s%mathjax_config)
    call normalise(s%md_base_dir)
    call normalise(s%media_dir)
    call normalise(s%output_dir)
    call normalise(s%page_dir)
    call normalise_list(s%copy_subdir)
    call normalise_list(s%exclude_dir)
    call normalise_list(s%html_template_dir)
    call normalise_list(s%include)
    call normalise_list(s%src_dir)
    if (s%relative) s%project_url = s%output_dir
    s%creation_date = strftime(s%creation_date)

    do k = 1, size(s%src_dir)
        if (s%src_dir(k)%s == s%output_dir .or. starts_with(s%src_dir(k)%s, s%output_dir//'/')) then
            stat = 1
            errmsg = 'Source directory '//s%src_dir(k)%s//' is a subdirectory of output directory '//s%output_dir
            return
        end if
    end do
    if (.not. s%preprocess) s%fpp_extensions = [string_t ::]

contains

    !> Make `path` absolute, if it is set.
    subroutine normalise(path)
        character(len=:), allocatable, intent(inout) :: path    !! the path
        if (allocated(path)) path = resolve_path(s%directory, path)
    end subroutine normalise

    !> Make every path in `list` absolute.
    subroutine normalise_list(list)
        type(string_t), intent(inout) :: list(:)    !! the paths
        integer :: j
        do j = 1, size(list)
            list(j)%s = resolve_path(s%directory, list(j)%s)
        end do
    end subroutine normalise_list

end subroutine finish_settings

Graphs

Calls

Called by