Skip to content
This repository was archived by the owner on Feb 16, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Sami/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,25 @@ public function getNamespaceInterfaces($namespace)
return $this->namespaceInterfaces[$namespace];
}

public function getNamespaceSubNamespaces($parent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just get the subnamespaces by parsing the namespace?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate? What information could I extract from the parent
namespace about the sub namespaces? You would need to walk the namespace
array to find it's children.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this PR would close #119, providing a list of child namespaces on a namespace page.

{
$prefix = $parent;
if (strlen($prefix)) {
$prefix .= '\\';
}
$len = strlen($prefix);

$subNamespaces = array();

foreach ($this->namespaces as $sub) {
if (substr($sub, 0, $len) == $prefix && strpos(substr($sub, $len), '\\') === false) {
$subNamespaces[$sub] = $sub;
}
}

return $subNamespaces;
}

public function addClass(ClassReflection $class)
{
$this->classes[$class->getName()] = $class;
Expand Down
1 change: 1 addition & 0 deletions Sami/Renderer/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ protected function renderNamespaceTemplates(array $namespaces, Project $project,

$variables = array(
'namespace' => $namespace,
'namespaces' => $project->getNamespaceSubNamespaces($namespace),
'classes' => $project->getNamespaceClasses($namespace),
'interfaces' => $project->getNamespaceInterfaces($namespace),
'exceptions' => $project->getNamespaceExceptions($namespace),
Expand Down
10 changes: 10 additions & 0 deletions Sami/Resources/themes/default/namespace.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@
{% block content %}
<h1>{{ namespace_link(namespace, {'target': 'main'}) }}</h1>

{% if namespaces %}
<h2>Namespaces</h2>
<ul>
{% for subnamespace in namespaces %}
<li>{{ namespace_link(subnamespace, {'target': 'main' }) }}</li>
{% endfor %}
</ul>
{% endif %}

{% if classes %}
<h2>Classes</h2>
<ul>
{% for class in classes %}
<li>{{ class_link(class, {'target': 'main'}) }}</li>
Expand Down
17 changes: 15 additions & 2 deletions Sami/Resources/themes/default/pages/namespace.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends page_layout %}

{% from "macros.twig" import class_link %}
{% from "macros.twig" import class_link, namespace_link %}

{% block title %}{{ namespace }} | {{ parent() }}{% endblock %}

Expand All @@ -12,7 +12,20 @@
{% endblock %}

{% block content %}
{% if namespaces %}
<h2>Namespaces</h2>
<table>
{% for subnamespace in namespaces %}
<tr>
<td>{{ namespace_link(subnamespace, {'target': 'main' }) }}</td>
<td class="last">&nbsp;</td>
</tr>
{% endfor %}
</table>
{% endif %}

{% if classes %}
<h2>Classes</h2>
<table>
{% for class in classes %}
<tr>
Expand All @@ -22,7 +35,7 @@
{% endfor %}
</table>
{% endif %}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this was added by mistake.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found some issues with this PR, so I'm working on an alternative that I'll submit this weekend.

On Aug 23, 2014, at 1:39 AM, Alexander Obuhovich [email protected] wrote:

In Sami/Resources/themes/default/pages/namespace.twig:

@@ -22,7 +35,7 @@
{% endfor %}

{% endif %}

  • I guess this was added by mistake.


Reply to this email directly or view it on GitHub.

{% if interfaces %}
<h2>Interfaces</h2>
<table>
Expand Down