-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebAPI: Add API description from Controller's POD #1559
Conversation
wow, that looks very promising. I would like to test that. |
https://build.opensuse.org/request/show/563765 created to provide the dependency for openSUSE but needs perl-HTML-Stream which we don't have. Couldn't test it locally :( |
lib/OpenQA/WebAPI.pm
Outdated
@@ -553,5 +571,110 @@ sub run { | |||
Mojolicious::Commands->start_app('OpenQA::WebAPI'); | |||
} | |||
|
|||
sub get_pod_from_controllers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to move this to it's own package along with _get_pod_text and related methods so that webAPI has a single responsability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So ... OpenQA::WebAPI::Documentation?
lib/OpenQA/WebAPI.pm
Outdated
$desc = _get_pod_text($i) if $i->is_ordinary(); | ||
} | ||
} | ||
$methods_description{$controller . '#' . $methodname} = $desc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to build the srting first, and then use it to avoid perl critic complains: https://travis-ci.org/os-autoinst/openQA/jobs/327749143#L652
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Will do that.
fc656fe
to
9ff74d2
Compare
Codecov Report
@@ Coverage Diff @@
## master #1559 +/- ##
==========================================
- Coverage 88.67% 88.44% -0.24%
==========================================
Files 116 117 +1
Lines 8696 8764 +68
==========================================
+ Hits 7711 7751 +40
- Misses 985 1013 +28
Continue to review full report at Codecov.
|
@foursixnine Decided on OpenQA::WebAPI::Description. Let me know if this package name and location is OK. |
lib/OpenQA/WebAPI/Description.pm
Outdated
@@ -0,0 +1,155 @@ | |||
# Copyright (C) 2012-2017 SUSE LLC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2018?
don't merge this before we have a package for pod::tree |
Will investigate Pod::POM as an alternative to Pod::Tree. perl-Pod-POM already exists as a package for opensuse, so if the functionality is equivalent, should be a better option. |
@coolo, @foursixnine, @okurz: reimplemented the POD walking methods in |
@alvarocarvajald Awesome! :) Remember to tidy up too :) |
@foursixnine I did tidy up. :) From what I can see in my system, files that are complaining on the tidy test are: ./lib/OpenQA/Resource/Jobs.pm Which aren't touched by this PR. Should I tidy those as well as part of this PR? |
@coolo did a tidy commit recently. Maybe you just need to rebase? |
I guess he uses an old perltidy |
This commit adds methods into lib/OpenQA/WebAPI.pm to parse the Controller/API/V1 module files for POD documentation, and extract from there API descriptions to be shown in the GUI's help page. In order to parse POD, the module Tree::Pod was also added to the required modules for the project.
06079ff
to
d3a57fa
Compare
Updated perltidy as suggested and fixed a small issue in lib/OpenQA/WebAPI/Controller/API/V1/Locks.pm. Now it's not reporting any files in my local system ... let's see what travis reports. |
I don't mind merging it - but I consider 34 commits a bit tough - please squash to 1-5 commits |
Add POD documentation to Controller/API/V1/Feature.pm Add POD documentation to Controller/API/V1/JobGroup.pm Add POD documentation to Controller/API/V1/Worker.pm
WebAPI: Remove uses of $_[0] in support methods WebAPI: Build file#method key before use in hash WebAPI: Move Pod::Tree->set_filename call Move call to Pod::Tree->set_filename in get_pod_from_controllers() to avoid warnings when the file is not loaded Move methods used to parse POD from API controller modules and to set API descriptions to OpenQA::WebAPI::Description. Remove unnecessary call to log_warning Fix copyright date Verify module file existance before parsing Change if for unless in OpenQA::WebAPI::Description To improve readibility
Add POD documentation to Controller/API/V1/Job.pm Add POD documentation to Controller/API/V1/Locks.pm
This commits reimplements the OpenQA::WebAPI::Description package to use Pod::POM instead of Pod::Tree. The file cpanfile with the required modules was also changed to reflect this. Tidy lib/OpenQA/WebAPI.pm Tidy lib/OpenQA/WebAPI/Controller/API/V1/Locks.pm
t/27-errorpages.t: Update API description to check Due to changes from commit os-autoinst@fd50a10, API descriptions are taken from the POD documentation in the Controller/API/V1/*.pm files; as such the text used to check the description in t/27-errorpages.t needs to be updated accordingly. Change the API description string to check. Fix test text in t/27-errorpages.t Better test string in t/27-errorpages.t Tidy t/27-errorpages.t
Add POD documentation Controller/API/V1/Asset.pm Add POD documentation to Controller/API/V1/Bug.pm Add POD documentation to Controller/API/V1/Command.pm Add POD documentation to Controller/API/V1/Comment.pm Add POD documentation to Controller/API/V1/Iso.pm Add description for /api/v1 root api path Add POD documentation to Controller/API/V1/JobTemplate.pm Add POD documentation for Controller/API/V1/Mm.pm Add METHODS heading in Controller/API/V1/* PODs Add POD documentation to Controller/API/V1/Table.pm
d56cab8
to
70e15bf
Compare
Squashed to 8 to keep some order between the different commits. Hope that's ok. |
ok, fair compromise :) |
commit 8d54de2 Merge: 3977d2f 70e15bf Author: Stephan Kulow <stephan@kulow.org> AuthorDate: Tue Feb 13 21:49:09 2018 +0100 Commit: GitHub <noreply@github.com> CommitDate: Tue Feb 13 21:49:09 2018 +0100 Merge pull request #1559 from alvarocarvajald/poo#16282 WebAPI: Add API description from Controller's POD
This PR adds the package OpenQA::WebAPI::Description which contains methods to be used on lib/OpenQA/WebAPI.pm to parse the Controller/API/V1 module files for POD documentation, and extract from there API descriptions to be shown in the GUI's help page.
In order to parse POD, the module Pod::POM was also added to the required modules for the project.
POD documentation was added to three API controller modules:
lib/OpenQA/WebAPI/Controller/API/V1/Feature.pm
lib/OpenQA/WebAPI/Controller/API/V1/JobGroup.pm
lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm
lib/OpenQA/WebAPI/Controller/API/V1/Job.pm
lib/OpenQA/WebAPI/Controller/API/V1/Locks.pm
Adding POD documentation to the remaining modules, should populate API descriptions in the help page automatically.