subroutineset_docprivate
subroutine set_doc(e, s, lines)
Set the documentation and metadata of e from its doc lines.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| e | type(entity_t) | inout | the entity | |
| s | type(settings_t) | in | the settings | |
| lines | type(string_t) | in | dimension(:) | the doc lines |
Calls
Source
Show the code
subroutine set_doc(e, s, lines)
type(entity_t), intent(inout) :: e !! the entity
type(settings_t), intent(in) :: s !! the settings
type(string_t), intent(in) :: lines(:) !! the doc lines
type(string_t), allocatable :: work(:), moved(:)
type(metadata_t) :: meta
integer :: k, at
allocate (e%meta(0))
if (size(lines) == 0) then
allocate (e%doc(0))
return
end if
work = lines
if (s%doxygen) then
! doxygen commands such as `@brief text` are metadata, wherever they are
allocate (moved(0))
do k = 1, size(work)
call doxygen_meta(work(k)%s, moved)
end do
work = [moved, work]
end if
if (size(work) == 1) then
at = index(work(1)%s, ':')
if (at > 0) then
if (index(META_KEYS, ' '//lowercase(strip(work(1)%s(:at - 1)))//' ') == 0) work = [string_t(''), work]
end if
end if
call parse_metadata(join(work, achar(10)), meta)
call move_alloc(meta%body, e%doc)
deallocate (e%meta)
allocate (e%meta(size(meta%items)))
do k = 1, size(meta%items)
e%meta(k)%key = meta%items(k)%key
e%meta(k)%values = meta%items(k)%values
end do
end subroutine set_doc