diff --git a/.travis.yml b/.travis.yml index 37fdc85..3f69eaa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +dist: trusty + language: php sudo: false diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 2baac26..a2cecf6 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -18,9 +18,16 @@ class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $treeBuilder - ->root('nelmio_api_doc') + $treeBuilder = new TreeBuilder('nelmio_api_doc'); + + if (method_exists($treeBuilder, 'getRootNode')) { + $rootNode = $treeBuilder->getRootNode(); + } else { + // symfony < 4.2 support + $rootNode = $treeBuilder->root('nelmio_api_doc'); + } + + $rootNode ->children() ->scalarNode('name')->defaultValue('API documentation')->end() ->arrayNode('exclude_sections') @@ -31,7 +38,7 @@ class Configuration implements ConfigurationInterface ->arrayNode('motd') ->addDefaultsIfNotSet() ->children() - ->scalarNode('template')->defaultValue('NelmioApiDocBundle::Components/motd.html.twig')->end() + ->scalarNode('template')->defaultValue('@NelmioApiDoc/Components/motd.html.twig')->end() ->end() ->end() ->arrayNode('request_listener') diff --git a/Formatter/HtmlFormatter.php b/Formatter/HtmlFormatter.php index 94ab16f..ec2c90c 100644 --- a/Formatter/HtmlFormatter.php +++ b/Formatter/HtmlFormatter.php @@ -12,6 +12,7 @@ namespace Nelmio\ApiDocBundle\Formatter; use Symfony\Component\Templating\EngineInterface; +use Twig\Environment as TwigEnvironment; class HtmlFormatter extends AbstractFormatter { @@ -31,7 +32,7 @@ class HtmlFormatter extends AbstractFormatter protected $defaultRequestFormat; /** - * @var EngineInterface + * @var EngineInterface|TwigEnvironment */ protected $engine; @@ -113,9 +114,9 @@ class HtmlFormatter extends AbstractFormatter } /** - * @param EngineInterface $engine + * @param EngineInterface|TwigEnvironment $engine */ - public function setTemplatingEngine(EngineInterface $engine) + public function setTemplatingEngine($engine) { $this->engine = $engine; } @@ -197,7 +198,7 @@ class HtmlFormatter extends AbstractFormatter */ protected function renderOne(array $data) { - return $this->engine->render('NelmioApiDocBundle::resource.html.twig', array_merge( + return $this->engine->render('@NelmioApiDoc/resource.html.twig', array_merge( array( 'data' => $data, 'displayContent' => true, @@ -211,7 +212,7 @@ class HtmlFormatter extends AbstractFormatter */ protected function render(array $collection) { - return $this->engine->render('NelmioApiDocBundle::resources.html.twig', array_merge( + return $this->engine->render('@NelmioApiDoc/resources.html.twig', array_merge( array( 'resources' => $collection, ), diff --git a/Resources/config/formatters.xml b/Resources/config/formatters.xml index 9d55d21..54f5eb5 100644 --- a/Resources/config/formatters.xml +++ b/Resources/config/formatters.xml @@ -21,7 +21,7 @@ - + %nelmio_api_doc.motd.template% diff --git a/Resources/doc/configuration-reference.rst b/Resources/doc/configuration-reference.rst index a4cbddb..d72ba35 100644 --- a/Resources/doc/configuration-reference.rst +++ b/Resources/doc/configuration-reference.rst @@ -8,7 +8,7 @@ Configuration Reference exclude_sections: [] default_sections_opened: true motd: - template: 'NelmioApiDocBundle::Components/motd.html.twig' + template: '@NelmioApiDoc/Components/motd.html.twig' request_listener: enabled: true parameter: _doc diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig index 54fafeb..25fdd84 100644 --- a/Resources/views/method.html.twig +++ b/Resources/views/method.html.twig @@ -189,7 +189,7 @@ {{ name }} {{ infos.dataType }} - {% include 'NelmioApiDocBundle:Components:version.html.twig' with {'sinceVersion': infos.sinceVersion, 'untilVersion': infos.untilVersion} only %} + {% include '@NelmioApiDoc/Components/version.html.twig' with {'sinceVersion': infos.sinceVersion, 'untilVersion': infos.untilVersion} only %} {{ infos.description }} {% endfor %} diff --git a/Resources/views/resource.html.twig b/Resources/views/resource.html.twig index 1a51099..07230e2 100644 --- a/Resources/views/resource.html.twig +++ b/Resources/views/resource.html.twig @@ -1,11 +1,11 @@ -{% extends "NelmioApiDocBundle::layout.html.twig" %} +{% extends "@NelmioApiDoc/layout.html.twig" %} {% block content %}
      • - {% include 'NelmioApiDocBundle::method.html.twig' %} + {% include '@NelmioApiDoc/method.html.twig' %}
    diff --git a/Resources/views/resources.html.twig b/Resources/views/resources.html.twig index 997153d..a6d2ca7 100644 --- a/Resources/views/resources.html.twig +++ b/Resources/views/resources.html.twig @@ -1,4 +1,4 @@ -{% extends "NelmioApiDocBundle::layout.html.twig" %} +{% extends "@NelmioApiDoc/layout.html.twig" %} {% block content %}
    @@ -33,7 +33,7 @@
    • {% for data in methods %} - {% include 'NelmioApiDocBundle::method.html.twig' %} + {% include '@NelmioApiDoc/method.html.twig' %} {% endfor %}
  • diff --git a/Tests/Formatter/testFormat-result-no-dunglas.markdown b/Tests/Formatter/testFormat-result-no-dunglas.markdown index 5739788..281df3f 100644 --- a/Tests/Formatter/testFormat-result-no-dunglas.markdown +++ b/Tests/Formatter/testFormat-result-no-dunglas.markdown @@ -622,6 +622,9 @@ dependency_type[a]: _This method is useful to test if the getDocComment works._ +This method is useful to test if the getDocComment works. +And, it supports multilines until the first '@' char. + #### Requirements #### **id** diff --git a/Tests/Formatter/testFormat-result.markdown b/Tests/Formatter/testFormat-result.markdown index cf3f8d9..2c16f07 100644 --- a/Tests/Formatter/testFormat-result.markdown +++ b/Tests/Formatter/testFormat-result.markdown @@ -706,6 +706,9 @@ dependency_type[a]: _This method is useful to test if the getDocComment works._ +This method is useful to test if the getDocComment works. +And, it supports multilines until the first '@' char. + #### Requirements #### **id**