Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
851cc344
Commit
851cc344
authored
6 months ago
by
Oliver Heidmann
Browse files
Options
Downloads
Patches
Plain Diff
section extraction from help fixed
parent
9eb4e577
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!289
M300433/python interaface integration 1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/module_info.cc
+68
-5
68 additions, 5 deletions
src/module_info.cc
src/module_info.h
+1
-1
1 addition, 1 deletion
src/module_info.h
with
69 additions
and
6 deletions
src/module_info.cc
+
68
−
5
View file @
851cc344
...
...
@@ -58,34 +58,50 @@ ModListOptions::parse_request(const std::string &requestString)
return
true
;
}
std
::
pair
<
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
,
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>>
std
::
pair
<
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
,
std
::
map
<
std
::
string
,
std
::
pair
<
std
::
string
,
std
::
vector
<
std
::
string
>>>
>
create_help_sections
(
const
CdoHelp
&
p_help
)
{
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
sections
=
{};
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
operators
=
{};
std
::
map
<
std
::
string
,
std
::
string
>
oper_synopsis
=
{};
std
::
string
key
;
std
::
string
operator_name
;
bool
operator_section_active
=
true
;
bool
synopsis_active
=
true
;
for
(
auto
&
line
:
p_help
)
{
std
::
cout
<<
line
<<
std
::
endl
;
bool
is_all_caps
=
std
::
all_of
(
begin
(
line
),
end
(
line
),
[](
char
c
)
{
return
isupper
(
c
);
});
if
(
line
.
compare
(
"OPERATORS"
)
==
0
)
{
operator_section_active
=
true
;
synopsis_active
=
false
;
}
else
if
(
line
.
compare
(
"SYNOPSIS"
)
==
0
)
{
key
=
line
;
operator_section_active
=
false
;
synopsis_active
=
true
;
}
else
if
(
is_all_caps
==
true
)
{
key
=
line
;
sections
[
key
]
=
std
::
vector
<
std
::
string
>
();
operator_section_active
=
false
;
synopsis_active
=
false
;
}
else
if
(
operator_section_active
==
true
)
{
if
(
line
.
find_first_not_of
(
' '
)
==
4
)
int
op_name_padding
=
4
;
if
(
line
.
find_first_not_of
(
' '
)
==
op_name_padding
)
{
operator_name
=
line
.
substr
(
4
,
line
.
find
(
' '
,
4
));
int
first_space_after_name
=
line
.
find_first_of
(
' '
,
op_name_padding
);
int
name_length
=
first_space_after_name
-
op_name_padding
;
operator_name
=
line
.
substr
(
op_name_padding
,
name_length
);
operators
[
operator_name
]
=
std
::
vector
<
std
::
string
>
{
std
::
string
(
line
)
};
}
else
...
...
@@ -93,13 +109,60 @@ create_help_sections(const CdoHelp &p_help)
operators
[
operator_name
].
push_back
(
std
::
string
(
line
));
}
}
else
if
(
synopsis_active
==
true
)
{
//std::cout << "we found a synopsis" << std::endl;
int
op_name_padding
=
4
;
std
::
size_t
general_op_desc_pos
=
line
.
find
(
"<operator>"
);
if
(
general_op_desc_pos
!=
std
::
string
::
npos
){
//std::cout << "we found a <operator>" << std::endl;
constexpr
std
::
size_t
len_generic
=
std
::
string
(
"<operator>"
).
size
();
auto
cleaned_line
=
std
::
string
(
line
).
erase
(
0
,
general_op_desc_pos
+
len_generic
);
std
::
cout
<<
cleaned_line
<<
" "
<<
general_op_desc_pos
<<
std
::
endl
;
sections
[
"SYNOPSIS"
]
=
{
cleaned_line
};
}
else
if
(
line
.
find_first_not_of
(
' '
)
==
op_name_padding
)
{
int
first_space_after_name
=
line
.
find_first_of
(
"[, "
,
op_name_padding
);
int
name_length
=
first_space_after_name
-
op_name_padding
;
operator_name
=
line
.
substr
(
op_name_padding
,
name_length
);
oper_synopsis
[
operator_name
]
=
std
::
string
(
line
);
std
::
cout
<<
"we added "
<<
line
<<
" to "
<<
operator_name
<<
std
::
endl
;
}
}
else
{
sections
[
key
].
push_back
(
std
::
string
(
line
));
}
}
return
std
::
make_pair
(
sections
,
operators
);
std
::
cout
<<
"we got here "
<<
__LINE__
<<
" "
<<
__FILE__
<<
std
::
endl
;
std
::
map
<
std
::
string
,
std
::
pair
<
std
::
string
,
std
::
vector
<
std
::
string
>>>
oper_syn_map
;
for
(
const
auto
&
op
:
operators
){
std
::
string
syn
=
""
;
auto
it
=
oper_synopsis
.
find
(
op
.
first
);
if
(
it
!=
oper_synopsis
.
end
()){
syn
=
oper_synopsis
[
op
.
first
];
std
::
cout
<<
"LOOK HERE "
<<
syn
<<
std
::
endl
;
oper_synopsis
.
erase
(
it
);
}
else
{
std
::
cout
<<
op
.
first
<<
std
::
endl
;
std
::
cout
<<
(
sections
.
find
(
"SYNOPSIS"
)
!=
sections
.
end
())
<<
std
::
endl
;
syn
=
" "
+
op
.
first
+
" "
+
sections
[
"SYNOPSIS"
][
0
];
}
std
::
cout
<<
syn
<<
std
::
endl
;
oper_syn_map
[
op
.
first
]
=
std
::
make_pair
(
syn
,
op
.
second
);
}
for
(
auto
&
syn
:
oper_synopsis
){
std
::
cout
<<
"added "
<<
syn
.
first
<<
" to map, with value = "
<<
syn
.
second
<<
std
::
endl
;
oper_syn_map
[
syn
.
first
].
first
=
syn
.
second
;
}
return
std
::
make_pair
(
sections
,
oper_syn_map
);
}
std
::
string
...
...
This diff is collapsed.
Click to expand it.
src/module_info.h
+
1
−
1
View file @
851cc344
...
...
@@ -27,7 +27,7 @@ struct ModListOptions
std
::
string
get_operator_description
(
const
std
::
string
&
p_current_op_name
,
const
std
::
vector
<
std
::
string
>
&
p_help
);
void
operator_print_list
(
ModListOptions
&
p_modListOpt
);
std
::
pair
<
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
,
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>>
std
::
pair
<
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
,
std
::
map
<
std
::
string
,
std
::
pair
<
std
::
string
,
std
::
vector
<
std
::
string
>>>
>
create_help_sections
(
const
CdoHelp
&
p_help
);
void
cdo_print_help
(
const
char
**
help
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment