fdoc

subroutinewrite_site

subroutine write_site(p, s, front, pages_in, count, stat, errmsg)

Write the whole site.

Arguments

NameTypeIntentAttributesDescription
ptype(project_t)inouttarget

the project

stype(settings_t)intarget

the settings

frontcharacter(len=*)in

the project file's text as HTML

pages_intype(page_t)intargetdimension(:)

the static pages

countintegerout

how many pages were written

statintegerout

nonzero on failure

errmsgcharacter(len=:)outallocatable

what is wrong

Calls

Source

Show the code
subroutine write_site(p, s, front, pages_in, count, stat, errmsg)
    type(project_t), intent(inout), target :: p         !! the project
    type(settings_t), intent(in), target :: s           !! the settings
    character(len=*), intent(in) :: front               !! the project file's text as HTML
    type(page_t), intent(in), target :: pages_in(:)     !! the static pages
    integer, intent(out) :: count                       !! how many pages were written
    integer, intent(out) :: stat                        !! nonzero on failure
    character(len=:), allocatable, intent(out) :: errmsg !! what is wrong
    type(site_t) :: site
    type(string_t), allocatable :: pages(:), paths(:)
    integer, allocatable :: ids(:)
    character(len=:), allocatable :: url, directory
    type(buffer_t) :: b
    integer :: k, n, extra

    site%p => p
    site%s => s
    site%pages => pages_in
    call collect_lists(site)
    call make_footer(s, site%footer)
    call locate_sources(site)
    call measure_files(site)

    allocate (ids(0))
    do k = 1, p%list%n
        if (has_page(site, k)) call push_int(ids, k)
    end do
    n = size(ids)
    call build_graphs(p, s, ids, [LIST_FILES, LIST_MODULES, LIST_PROCEDURES, LIST_TYPES], site%graphs, stat, errmsg)
    if (stat /= 0) return
    allocate (site%graphs_of(p%list%n))
    do k = 1, size(site%graphs%graphs)
        if (site%graphs%graphs(k)%owner > 0) then
            call push_int(site%graphs_of(site%graphs%graphs(k)%owner)%ids, k)
        end if
    end do
    extra = size(pages_in) + 1
    allocate (pages(n + NUM_LISTS + 1 + extra), paths(n + NUM_LISTS + 1 + extra))
    count = 0

    directory = s%output_dir
    call make_directory(directory, stat)
    do k = 1, size(SITE_DIRECTORIES)
        if (stat /= 0) exit
        call make_directory(directory//'/'//trim(SITE_DIRECTORIES(k)), stat)
    end do
    if (stat /= 0) then
        errmsg = 'could not create '//directory
        return
    end if
    call page_directories(directory, pages_in)

    call write_entity_pages(site, ids, directory, count, stat, errmsg)
    if (stat /= 0) return

    do k = 1, NUM_LISTS
        paths(n + k)%s = 'lists/'//trim(LIST_FILE(k))//'.html'
        if (size(site%members(k)%ids) > 0) call list_page(site, k, pages(n + k)%s)
    end do
    paths(n + NUM_LISTS + 1)%s = 'index.html'
    call index_page(site, front, pages(n + NUM_LISTS + 1)%s)
    do k = 1, size(pages_in)
        paths(n + NUM_LISTS + 1 + k)%s = 'page/'//pages_in(k)%path
        call static_page(site, k, pages(n + NUM_LISTS + 1 + k)%s)
    end do
    paths(size(paths))%s = 'search.html'
    if (s%search) call search_page(site, pages(size(paths))%s)

    call progress_start('Writing files', size(pages))
    do k = 1, size(pages)
        call progress_tick()
        if (.not. allocated(pages(k)%s)) cycle
        count = count + 1
        call write_whole_file(directory//'/'//paths(k)%s, pages(k)%s, stat, errmsg)
        if (stat /= 0) return
    end do
    call progress_finish()
    call asset_fdoc_css(b)
    call take(b, url)
    call write_whole_file(directory//'/css/fdoc.css', url, stat, errmsg)
    if (stat /= 0) return
    call asset_fdoc_js(b)
    call take(b, url)
    call write_whole_file(directory//'/js/fdoc.js', url, stat, errmsg)
    if (stat /= 0) return
    call sidebar_script(site, url)
    call write_whole_file(directory//'/js/sidebar.js', url, stat, errmsg)
    if (stat /= 0) return
    if (s%search) then
        call search_index(site, url)
        call write_whole_file(directory//'/search/index.js', url, stat, errmsg)
        if (stat /= 0) return
    end if
    call copy_page_files(s, directory, pages_in)
    if (allocated(s%css)) call copy_file(s%css, directory//'/css/user.css', k)
    if (allocated(s%favicon)) call copy_file(s%favicon, directory//'/favicon.png', k)
    call logo_name(s, url)
    if (len(url) > 0) then
        call copy_file(s%logo, directory//'/'//url, k)
    else if (allocated(s%logo)) then
        call warn('the logo '//s%logo//' was not found, so the main page has none')
    end if
    if (allocated(s%media_dir)) then
        if (is_directory(s%media_dir)) then
            call remove_directory(directory//'/media')
            call copy_path(s%media_dir, directory//'/media', k)
        end if
    end if
end subroutine write_site

Graphs

Calls

write_sitecollect_listsmake_footerlocate_sourcesmeasure_filespush_inthas_pagebuild_graphsmake_directorypage_directorieswrite_entity_pageslist_pageindex_pagestatic_pagesearch_pageprogress_startprogress_tickwrite_whole_fileprogress_finishasset_fdoc_csstakeasset_fdoc_jssidebar_scriptsearch_indexcopy_page_filescopy_filelogo_namewarnremove_directorycopy_pathlist_ofsort_idsaddhtml_escapelicense_textis_procedurewants_sourcelocate_in_filecount_sourceentity_urlbuild_relationsgraphs_wantedint_textdraw_graphsunique_tagis_windowsrun_commandquoted_pathlast_separatorwrite_entity_pagepage_headsite_sidedisplay_namelist_columnsstats_cellsstats_totalwrite_graphpage_footicon_linkpage_linksdrawseconds_textside_iconadd_js_textplain_textsorts_beforeparse_boollower_in_placeconstruct_linesfind_sourceobject_wordpage_nameurl_quoteconnectvisible_callsparse_intdraw_somequotedentity_pagelink_tobadgeprocedure_badgesnumber_celladd_intsize_textadd_statsbar_textletter_classstarts_withpermission_ranklower_charline_hasstarts_wordpushis_simple_bindingstripdraw_graphchildren_ofside_grouppage_outlineuses_mathentity_titleprocedure_bodyinterface_bodytype_bodyadd_wordsfile_bodyunit_bodygraph_sectionsargument_tableenum_sectionscommon_sectionssummary_sectionis_shownexplained_badgegroupedword_atdescribe_graphacceptscontains_stringhas_mathbreadcrumbsjoinsignatureuses_sectioncalls_sectionsource_sectionwrite_call_formssummary_itembinding_tablehighlight_fortrananchorwrite_typeargument_attributessection_idgrow_edgesadd_nodeadd_edgesignature_argumentsform_keywrite_formline_startis_intrinsicentity_anchornode_linkdescribeis_elementalrank_labellabel_resultssort_intscall_textshared_summaryspecific_linkrank_ofargument_name

Called by