Skip to content

Commit a22875d

Browse files
committed
Rebrand documentation intelligence to code intelligence
1 parent fb92ae1 commit a22875d

File tree

5 files changed

+52
-20
lines changed

5 files changed

+52
-20
lines changed

monorepo/DocumentationIntelligence/DocumentationIntelligence.php monorepo/CodeIntelligence/CodeIntelligence.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
$this->info('Generating documentation intelligence...');
3535
$this->line();
3636

37-
$generator = new DocumentationIntelligence();
37+
$generator = new CodeIntelligence();
3838

3939
task('discover pages', fn () => $generator->discoverPages());
4040
task('assemble model', fn () => $generator->assembleModel());
@@ -71,7 +71,7 @@
7171
return 0;
7272
});
7373

74-
class DocumentationIntelligence
74+
class CodeIntelligence
7575
{
7676
protected HydeKernel $kernel;
7777

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Internal Documentation Intelligence
1+
# Internal Code and Documentation Intelligence
22

3-
This internal monorepo module contains tools to analyse the documentation to improve its quality.
3+
This internal monorepo module contains tools to analyse the documentation and codebase to improve its quality.
44
All code here is internal and should not be used outside the monorepo and no support will be provided for it.
55

66
## Usage
@@ -9,5 +9,5 @@ As the resulting data models and dashboards can get quite large, they are exclud
99
To generate them, run the following command:
1010

1111
```bash
12-
php monorepo/DocumentationIntelligence/DocumentationIntelligence.php
12+
php monorepo/CodeIntelligence/CodeIntelligence.php
1313
```

monorepo/DocumentationIntelligence/dashboard-template.php monorepo/CodeIntelligence/dashboard-template.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
6-
<title>HydePHP Documentation Intelligence Dashboard</title>
6+
<title>HydePHP Code Intelligence Dashboard</title>
77
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
88
<style>
99
.w-fit {
@@ -16,9 +16,9 @@
1616
<header class="container">
1717
<div class="row">
1818
<div class="col-12 py-4 text-center">
19-
<h1>HydePHP Documentation Intelligence Dashboard</h1>
19+
<h1>HydePHP Code Intelligence Dashboard</h1>
2020
<p class="lead">
21-
This internal monorepo module contains tools to analyse the documentation to improve its quality.
21+
This internal monorepo module contains tools to analyse the codebase and documentation to improve its quality.
2222
</p>
2323
</div>
2424
</div>

packages/framework/tests/Unit/Views/NavigationLinkViewTest.php

+44-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
namespace Hyde\Framework\Testing\Unit\Views;
66

7-
use Hyde\Foundation\Facades\Routes;
7+
use Hyde\Pages\InMemoryPage;
8+
use Hyde\Support\Models\Route;
9+
use Hyde\Testing\TestsBladeViews;
10+
use Hyde\Testing\Support\TestView;
11+
use Illuminate\View\ComponentAttributeBag;
812
use Hyde\Framework\Features\Navigation\NavItem;
913
use Hyde\Testing\TestCase;
1014

@@ -13,39 +17,67 @@
1317
*/
1418
class NavigationLinkViewTest extends TestCase
1519
{
20+
use TestsBladeViews;
21+
1622
protected function setUp(): void
1723
{
1824
parent::setUp();
1925
$this->mockRoute();
2026
$this->mockPage();
2127
}
2228

23-
protected function render(?NavItem $item = null): string
29+
protected function test(): TestView
2430
{
25-
return view('hyde::components.navigation.navigation-link', [
26-
'item' => $item ?? NavItem::forLink('foo.html', 'Foo'),
27-
])->render();
31+
return $this->test(view('hyde::components.navigation.navigation-link', [
32+
'item' => NavItem::forRoute(new Route(new InMemoryPage('foo')), 'Foo'),
33+
'attributes' => new ComponentAttributeBag(),
34+
]));
2835
}
2936

3037
public function testComponentLinksToRouteDestination()
3138
{
32-
$this->assertStringContainsString('href="foo.html"', $this->render());
39+
$this->test()->assertAttributeIs('href', 'foo.html');
40+
}
41+
42+
public function testComponentResolvesRelativeLinksForRoutes()
43+
{
44+
$this->mockCurrentPage('foo/bar');
45+
$this->test()->assertAttributeIs('href', '../foo.html');
3346
}
3447

3548
public function testComponentUsesTitle()
3649
{
37-
$this->assertStringContainsString('Foo', $this->render());
50+
$this->test()->assertTextIs('Foo');
51+
}
52+
53+
public function testComponentDoesNotHaveCurrentAttributesWhenCurrentRouteDoesNotMatch()
54+
{
55+
$this->test()
56+
->assertDontSee('current')
57+
->assertDoesNotHaveAttribute('aria-current');
3858
}
3959

4060
public function testComponentIsCurrentWhenCurrentRouteMatches()
4161
{
42-
$this->mockRoute(Routes::get('index'));
43-
$this->assertStringContainsString('current', $this->render(NavItem::forRoute(Routes::get('index'), 'Home')));
62+
$this->mockCurrentPage('foo')
63+
->test()
64+
->assertSee('current')
65+
->assertHasAttribute('aria-current')
66+
->assertAttributeIs('aria-current="page"');
67+
}
68+
69+
public function testComponentDoesNotHaveActiveClassWhenNotActive()
70+
{
71+
$this->test()
72+
->assertSee('navigation-link ')
73+
->assertDontSee('navigation-link-active');
4474
}
4575

46-
public function testComponentHasAriaCurrentWhenCurrentRouteMatches()
76+
public function testComponentHasActiveClassWhenActive()
4777
{
48-
$this->mockRoute(Routes::get('index'));
49-
$this->assertStringContainsString('aria-current="page"', $this->render(NavItem::forRoute(Routes::get('index'), 'Home')));
78+
$this->mockCurrentPage('foo')
79+
->test()
80+
->assertSee('navigation-link ')
81+
->assertSee('navigation-link-active');
5082
}
5183
}

0 commit comments

Comments
 (0)