functionrun
integer function run(args) result(status)
Run with command line args, returning the exit status.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| args | type(string_t) | in | dimension(:) | the arguments, in order |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| status | integer |
Calls
- parse_args
- usage
- markdown_list
- load_project
- check_settings
- apply_toml_string
- apply_args
- finish_settings
- dump_settings
- progress_enable
- warn_unsupported
- load_project_sources
- progress_start
- correlate
- link_project
- prune
- progress_finish
- write_text
- dump_links
- assign_pages
- base_options
- collect_abbreviations
- index_entity_names
- render_documentation
- render_text
- load_pages
- write_site
- write_modules
- progress_summary
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