Skip to content

Commit

Permalink
Merge pull request #108 from jvdp1/improve_markdown
Browse files Browse the repository at this point in the history
Improved Markdown output by adding some line breaks
  • Loading branch information
szaghi authored Dec 19, 2023
2 parents 5a63132 + 07fd931 commit 60ca869
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/lib/flap_command_line_argument_t.F90
Original file line number Diff line number Diff line change
Expand Up @@ -290,34 +290,38 @@ function usage(self, pref, markdown)
endselect
if (trim(adjustl(self%switch))/=trim(adjustl(self%switch_ab))) then
if (markdownd) then
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//usage//'`, `'//trim(adjustl(self%switch_ab))//usage//'`'
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//usage//'`, `'//trim(adjustl(self%switch_ab))//usage//'` '
else
usage = ' '//switch_//usage//', '//switch_ab_//usage
endif
else
if (markdownd) then
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//usage//'`'
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//usage//'` '
else
usage = ' '//switch_//usage
endif
endif
else
if (trim(adjustl(self%switch))/=trim(adjustl(self%switch_ab))) then
if (markdownd) then
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//' value`, `'//trim(adjustl(self%switch_ab))//' value'//'`'
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//' value`, `'//trim(adjustl(self%switch_ab))//' value'//'` '
else
usage = ' '//switch_//' value, '//switch_ab_//' value'
endif
else
if (markdownd) then
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//' value`'
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//' value` '
else
usage = ' '//switch_//' value'
endif
endif
endif
else
usage = ' value'
if (markdownd) then
usage = new_line('a')//'* value'
else
usage = ' value'
endif
endif
if (allocated(self%choices)) then
usage = usage//', value in: `'//self%choices//'`'
Expand All @@ -330,22 +334,28 @@ function usage(self, pref, markdown)
else
if (trim(adjustl(self%switch))/=trim(adjustl(self%switch_ab))) then
if (markdownd) then
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//'`, `'//trim(adjustl(self%switch_ab))//'`'
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//'`, `'//trim(adjustl(self%switch_ab))//'` '
else
usage = ' '//switch_//', '//switch_ab_
endif
else
if (markdownd) then
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//'`'
usage = new_line('a')//'* `'//trim(adjustl(self%switch))//'` '
else
usage = ' '//switch_
endif
endif
endif
prefd = '' ; if (present(pref)) prefd = pref
usage = prefd//usage
if (self%is_positional) usage = usage//new_line('a')//prefd//repeat(' ',indent)//trim(str(self%position, .true.))//&
'-th argument'
if (self%is_positional)then
! two spaces make a line break in markdown.
if (markdownd) then
usage = usage//' '
endif
usage = usage//new_line('a')//prefd//repeat(' ',4)//trim(str(self%position, .true.))//&
'-th argument'
endif
if (allocated(self%envvar)) then
if (self%envvar /= '') then
usage = usage//new_line('a')//prefd//repeat(' ',10)//'environment variable name "'//trim(adjustl(self%envvar))//'"'
Expand All @@ -363,9 +373,9 @@ function usage(self, pref, markdown)
endif
if (self%m_exclude/='') usage = usage//new_line('a')//prefd//repeat(' ', indent)//'mutually exclude "'//self%m_exclude//'"'
if (markdownd) then
usage = usage//' '//new_line('a')//prefd//repeat(' ',4)//trim(adjustl(self%help))
usage = usage//' '//new_line('a')//prefd//repeat(' ',4)//trim(adjustl(self%help))//' '
if (self%help_markdown/='') then
usage = usage//trim(adjustl(self%help_markdown))
usage = usage//trim(adjustl(self%help_markdown))//' '
endif
else
usage = usage//new_line('a')//prefd//repeat(' ', indent)//trim(adjustl(self%help))
Expand Down
2 changes: 2 additions & 0 deletions src/lib/flap_command_line_arguments_group_t.f90
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,15 @@ function usage(self, pref, no_header, markdown)
endif
if (self%Na_required>0) then
usage = usage//new_line('a')//new_line('a')//prefd//'Required switches:'
if(markdownd)usage = usage//' '
do a=1, self%Na
if (self%cla(a)%is_required.and.(.not.self%cla(a)%is_hidden)) usage = usage//new_line('a')//&
self%cla(a)%usage(pref=prefd,markdown=markdownd)
enddo
endif
if (self%Na_optional>0) then
usage = usage//new_line('a')//new_line('a')//prefd//'Optional switches:'
if(markdownd)usage = usage//' '
do a=1, self%Na
if (.not.self%cla(a)%is_required.and.(.not.self%cla(a)%is_hidden)) usage = usage//new_line('a')//&
self%cla(a)%usage(pref=prefd,markdown=markdownd)
Expand Down

0 comments on commit 60ca869

Please sign in to comment.