-
Notifications
You must be signed in to change notification settings - Fork 106
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
Sort docs by group
, group_index
#148
Conversation
Codecov Report
@@ Coverage Diff @@
## master #148 +/- ##
============================================
+ Coverage 43.40% 44.00% +0.59%
- Complexity 164 165 +1
============================================
Files 6 6
Lines 470 475 +5
============================================
+ Hits 204 209 +5
Misses 266 266
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
78cb3c2
to
0ba821a
Compare
@@ -119,15 +119,23 @@ public function filterByMethods($docs, $get, $post, $put, $path, $delete, $head) | |||
|
|||
public function groupDocs($docs, $group = 'default') | |||
{ | |||
if ($group === 'default') { |
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.
better than before, but still not quite there.
{
"uri": "api/v1/health",
"methods": [
"GET"
],
"middlewares": [
"api"
],
....
],
"group": "api/v1/health",
"group_index": 0
},
{
"uri": "api/v1/not-health",
"methods": [
"GET"
],
merged but will reopen the issue #143
Won't push new tag yet.
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.
Loop on UI is here
laravel-request-docs/ui/src/components/Sidebar.tsx
Lines 22 to 43 in 374f4f1
{lrdDocsJson.map((lrdDocsItem) => ( | |
lrdDocsItem.methods.map((method, methodIndex) => ( | |
<div key={shortid.generate()}> | |
{(lrdDocsItem.group != null && lrdDocsItem.group != "" && lrdDocsItem.group_index == 0 && methodIndex == 0) && ( | |
<li className="pt-5 text-slate-600"> | |
{/* Only in case of controller names full path -> just controller name */} | |
{lrdDocsItem.group.split('\\').pop()} | |
</li> | |
)} | |
<li> | |
<AnchorLink href={'#' + method + lrdDocsItem.uri} className="flex flex-row px-0 py-1"> | |
<span className={`method-${method} uppercase text-xs w-12 p-0 flex flex-row-reverse`}> | |
{method} | |
</span> | |
<span className="flex-1 p-0 text-sm text-left break-all"> | |
{lrdDocsItem.uri} | |
</span> | |
</AnchorLink> | |
</li> | |
</div> | |
)) | |
))} |
} | ||
|
||
return $docs; | ||
return collect($groupDocs)->sortBy(['group', 'group_index']) |
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.
Probably this
return collect($groupDocs)->groupBy(['group', 'group_index'])
->values()
->flatten(2)
->toArray();
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.
$groupBy = ['group', 'group_index'];
return collect($groupDocs)->groupBy($groupBy)
->values()
->flatten(count($groupBy))
->toArray();
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.
Fixes here #150
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.
Fix is fine but
ah UT failed, so will revert changes c938063
Will wait for your pull req
Fix #143