fdoc

functionrun

integer function run(args) result(status)

Run with command line args, returning the exit status.

Arguments

NameTypeIntentAttributesDescription
argstype(string_t)indimension(:)

the arguments, in order

Result

NameTypeAttributesDescription
statusinteger

Calls

Source

Show the code
integer function run(args) result(status)
    type(string_t), intent(in) :: args(:)   !! the arguments, in order
    type(args_t) :: parsed
    type(settings_t), target :: s
    type(project_t), target :: p
    type(markdown_options_t) :: options, front_options
    type(page_t), allocatable :: static(:)
    character(len=:), allocatable :: errmsg, body, directory, front
    character(len=16) :: count_text
    integer :: stat, pages

    status = 0
    call parse_args(args, parsed, stat, errmsg)
    if (stat /= 0) then
        write (error_unit, '(a)') 'fdoc: '//errmsg
        write (error_unit, '(a)') 'Try "fdoc --help".'
        status = 2
        return
    end if
    if (parsed%action == ACTION_HELP) then
        write (output_unit, '(a)', advance='no') usage()
        return
    end if
    if (parsed%action == ACTION_VERSION) then
        write (output_unit, '(a)') 'fdoc version '//VERSION
        return
    end if

    if (parsed%action == ACTION_MARKDOWN) then
        call markdown_list(parsed%project_file)
        return
    end if

    directory = '.'
    if (len(parsed%project_file) > 0) directory = parent_directory(parsed%project_file)
    call load_project(parsed%project_file, directory, s, body, stat, errmsg)
    if (stat == 0) call check_settings(s, stat, errmsg)
    if (stat == 0 .and. allocated(parsed%config)) call apply_toml_string(parsed%config, s, stat, errmsg)
    if (stat == 0) call apply_args(parsed, s, stat, errmsg)
    if (stat == 0) call finish_settings(s, directory, stat, errmsg)
    if (stat /= 0) then
        write (error_unit, '(a)') 'fdoc: '//errmsg
        status = 1
        return
    end if

    if (parsed%action == ACTION_DUMP) then
        write (output_unit, '(a)', advance='no') dump_settings(s)
        return
    end if

    if (parsed%action /= ACTION_DUMP_LINKS .and. .not. s%quiet) call progress_enable()
    call warn_unsupported(s)
    call load_project_sources(s, p, stat, errmsg)
    if (stat /= 0) then
        write (error_unit, '(a)') 'fdoc: '//errmsg
        status = 1
        return
    end if
    call progress_start('Connecting entities', p%list%n)
    call correlate(p, s)
    call link_project(p)
    call prune(p, s)
    call progress_finish()
    if (parsed%action == ACTION_DUMP_LINKS) then
        call write_text(dump_links(p))
        return
    end if
    call assign_pages(p)
    call base_options(s, '..', options)
    call collect_abbreviations(p, options)
    call index_entity_names(p%list)
    call render_documentation(p, s, options)
    call base_options(s, '.', front_options)
    if (allocated(options%abbreviations)) front_options%abbreviations = options%abbreviations
    call render_text(p, front_options, 0, '', body, front)
    call load_pages(p, s, options, static)
    call write_site(p, s, front, static, pages, stat, errmsg)
    if (stat == 0 .and. s%externalize) call write_modules(p, s, stat, errmsg)
    if (stat /= 0) then
        write (error_unit, '(a)') 'fdoc: '//errmsg
        status = 1
        return
    end if
    write (count_text, '(i0)') pages
    call progress_summary(trim(count_text)//' pages written to '//s%output_dir)
end function run

Graphs

Calls

runparse_argsusagemarkdown_listload_projectcheck_settingsapply_toml_stringapply_argsfinish_settingsdump_settingsprogress_enablewarn_unsupportedload_project_sourcesprogress_startcorrelatelink_projectpruneprogress_finishwrite_textdump_linksassign_pagesbase_optionscollect_abbreviationsindex_entity_namesrender_documentationrender_textload_pageswrite_sitewrite_modulesprogress_summarystarts_withpushmarkdown_to_htmlnew_settingsread_whole_fileload_fpm_settingsends_withparse_metadatajoinis_optionwarnset_optioncontains_stringsort_stringsadd_intrinsic_modulessplit_onapply_tableresolve_pathstrftimec_isattyfind_sourcesread_sourceruns_commandprogress_tickexpand_includesparse_filemerge_listdrawadd_external_moduleslink_usespublic_namesset_constructorinheritlink_implementationlink_callslink_submodulelink_module_procedureslink_bindinglink_constructorfind_symbollink_variableis_program_unitis_procedureseconds_textqualified_nameadd_linkslast_separatorpage_nameentity_urlindex_findindex_setint_textstriptop_levelrender_entityread_treecollect_listsmake_footerlocate_sourcesmeasure_filespush_inthas_pagebuild_graphsmake_directorypage_directorieswrite_entity_pageslist_pageindex_pagestatic_pagesearch_pagewrite_whole_fileasset_fdoc_csstakeasset_fdoc_jssidebar_scriptsearch_indexcopy_page_filescopy_filelogo_nameremove_directorycopy_pathentity_jsonsplit_linesnormalize_linesexpand_file_includesadmonition_linessubstitute_aliasesstash_fenced_codestash_html_blockscollect_definitionssplit_chunksparse_chunksrender_childrenrender_footnotesinsert_tocunstashis_markermatch_keyadd_valueleading_blanksin_setparse_boolset_logicalparse_intset_listset_mapset_textadd_entryscalar_textarray_valuesmap_valuesexpand_varshas_roothas_drivelexical_cleanday_of_yearweekdayglob_matchesextension_ofload_sourceneeds_fyppinclude_namelocatecollect_docslist_addentity_list_tset_docinherit_displayclose_unitnearest_callerstatement_callsstatement_textopen_unitparse_statementbar_textload_external_projectfind_moduleread_use_specadd_symbolgeneric_bodiesmodule_positionimport_namesoverridescopy_bindingcontext_oflabel_itemtype_bindingin_categorypublic_symbollower_charobject_wordurl_quotename_hashdedentsplit_wordsfirst_paragraphis_input_directoryread_pagepage_filelist_ofsort_idsaddhtml_escapelicense_textwants_sourcelocate_in_filecount_sourcebuild_relationsgraphs_wanteddraw_graphsunique_tagis_windowsrun_commandquoted_pathwrite_entity_pagepage_headsite_sidedisplay_namelist_columnsstats_cellsstats_totalwrite_graphpage_footicon_linkpage_linksside_iconadd_js_textplain_textpublic_symbolsadmonition_startfence_lengthfence_languagecode_block_htmlstash_htmltag_atelement_endremove_markdown_attributecount_newlinesfirst_line_ofnormal_idparse_blockrender_nodedigits_valuefypp_sourcepreprocessstarts_wordhas_markstrip_trailingdoxygen_metaapply_attributesattach_argumentsclose_interfaceleading_textis_executablechain_endadd_callread_associationsread_submoduleopen_procedureinherited_permissionread_type_statementread_useread_bindingread_finalread_module_proceduresread_namelistread_commonis_attribute_statementread_attribute_statementis_type_declarationread_declarationquotedremove_fileread_externaltop_splitvariable_typetype_memberfind_instem_lengthsorts_beforelower_in_placeconstruct_linesfind_sourceconnectvisible_callsdraw_someentity_pagelink_tobadgeprocedure_badgesnumber_celladd_intsize_textadd_statsletter_classhighlight_fortranword_atlast_childpush_backin_statelist_indentis_listcode_blockadmonition_blockfind_hash_headerhash_headeris_setextsetext_headerfind_ruleparse_onetrimmed_endnew_nodeis_ordered_itemlist_blockis_bullet_itemfind_quotequote_blockis_tablefind_definitiondefinition_blockparagraphrender_coderender_tableis_placeholderinlineattribute_listrender_headingis_digitfypp_processtemporary_directorypreprocessor_commandfirst_word_ofapply_onemark_common_membersimplicit_variabledoxygen_paramsremove_childis_intrinsicchain_startremove_blanksparse_procedure_headerparse_typeset_typetop_indexclosing_parensplit_attributesreplace_commastype_keywordparse_declaratorpermission_rankline_hasis_simple_bindingdraw_graphchildren_ofside_grouppage_outlineuses_mathentity_titleprocedure_bodyinterface_bodytype_bodyadd_wordsfile_bodyunit_bodygraph_sectionsargument_tableenum_sectionscommon_sectionssummary_sectionis_shownexplained_badgegroupedline_startindent_levelloose_detabset_stateparse_textreset_stateis_ruleitem_textlist_itemsadjustl_textrow_cellstable_rowinline_backslashinline_codeinline_bracketinline_imageinline_angleinline_entityinline_dollarinline_emphasisinline_abbreviationinline_smartunique_idinterncompilenew_nodeadd_bodyparse_fileevaluaterender_bodyfold_outputoriginal_prefixselector_lengthdescribe_graphacceptshas_mathbreadcrumbssignatureuses_sectioncalls_sectionsource_sectionwrite_call_formssummary_itembinding_tableanchorwrite_typeargument_attributessection_idmathford_linkbracket_endlink_targetwrite_linkfind_referenceencodedfirst_wordclosing_markfind_namenext_tokenparse_listfailmove_nodepush_idwithout_carriage_returnsparse_textlookuparithmeticmake_intmake_booltruth_ofcompareevaluate_callcall_methodsubscriptevaluate_slicerun_clausemove_valueevaluate_fstringrender_nodefold_regiongrow_edgesadd_nodeadd_edgesignature_argumentsform_keywrite_formentity_anchorname_and_entityis_blankread_stringread_namestarts_nameparse_testat_wordnew_exprskip_blanksflush_textend_of_lineread_line_directivehandle_directivetrim_rightmake_stringcompare_twoevaluate_argscall_macrocall_builtinequalformat_stringitems_ofwrite_valueis_spacesplit_stringcopy_itemsbind_targetsrecord_spanrender_loopassign_targetsdefine_macrorender_callfold_linenode_linkdescribeis_elementalrank_labellabel_resultssort_intscall_textshared_summaryspecific_linkin_nameparse_orexpectmove_exprappendtrim_lengthcontrol_directiveopen_scopedefineclose_scopemake_rangemake_zipcopy_valuevalue_tbind_onefold_positionrank_ofargument_nameparse_andopen_blockclose_blockfor_directiveset_directivedef_directivecall_directiveinclude_directiveframe_roomparse_notread_targetsparse_argumentsparse_compareparse_comprehensionparse_sumparse_productparse_unaryparse_postfixparse_primaryparse_subscriptparse_fstringparse_items