From b1f0b66b665460c7e24533794fe4963a816a15e0 Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Sat, 8 Feb 2025 11:27:50 +0100 Subject: [PATCH] improve wording and format on texts --- CHANGELOG.md | 8 ++-- README.markdown | 10 ++--- doc/01-Basic-Menus.md | 42 ++++++++----------- doc/01a-Advanced-Menu.md | 3 +- doc/02-Twig-Integration.md | 12 ++---- doc/03-Silex-Integration.md | 3 +- doc/04-Iterators.md | 16 +++---- doc/05-Matcher.md | 21 ++++------ doc/06-FAQ.md | 3 +- .../01_apply_active_class_to_whole_tree.md | 7 ++-- 10 files changed, 52 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a3cd220..39336e13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,7 +55,7 @@ * Added 2 new tests to twig: `knp_menu_current`, `knp_menu_ancestor` * Made the templates compatible with Twig 2 * Add menu and renderer providers supporting any ArrayAccess implementations. The - Pimple-based providers (supporting only Pimple 1) are dperecated in favor of these + Pimple-based providers (supporting only Pimple 1) are deprecated in favor of these new providers. ## 2.0.1 (2014-08-01) @@ -74,7 +74,7 @@ ## 2.0.0 alpha 2 (2014-05-01) * [BC break] Changed the TwigRenderer to accept a menu template only as a string -* [BC break] Refactored the way of rendering twig templates. Every template should extends +* [BC break] Refactored the way of rendering twig templates. Every template should extend the `knp_menu.html.twig` template. * Introduced extension points in the MenuFactory through `Knp\Menu\Factory\ExtensionInterface` * [BC break compared to 2.0 alpha 1] The inheritance extension points introduced in alpha1 are @@ -112,7 +112,7 @@ ) ``` - The old syntax is kept until the final release, but using it will trigger a E_USER_DEPRECATED error. + The old syntax is kept until the final release, but using it will trigger an E_USER_DEPRECATED error. ## 2.0.0 alpha 1 (2013-06-23) @@ -164,7 +164,7 @@ * Added a ChainProvider for the menus. * Added the Silex extension * Added a RouterAwareFactory -* Added an helper to be able to reuse the logic more easily for other templating engines +* Added a helper to be able to reuse the logic more easily for other templating engines * Added a way to retrieve an item using a path in a menu tree * Changed the toArray method to use a depth instead of simply using a boolean flag * Refactored the export to array and the creation from an array diff --git a/README.markdown b/README.markdown index 45bb1217..f16b9441 100644 --- a/README.markdown +++ b/README.markdown @@ -1,7 +1,6 @@ -KnpMenu -======= +# KnpMenu -The KnpMenu library provides object oriented menus for PHP. +The KnpMenu library provides object-oriented menus for PHP. It is used by the [KnpMenuBundle](https://github.com/KnpLabs/KnpMenuBundle) for Symfony but can now be used stand-alone. @@ -12,9 +11,9 @@ but can now be used stand-alone. ## Installation -KnpMenu uses Composer, please checkout the [composer website](https://getcomposer.org/) for more information. +KnpMenu uses Composer, please check out the [composer website](https://getcomposer.org/) for more information. -The simple following command will install `knp-menu` into your project. It also add a new +The simple following command will install `knp-menu` into your project. It also adds a new entry in your `composer.json` and update the `composer.lock` as well. ```bash @@ -96,3 +95,4 @@ the [Symfony community](https://github.com/KnpLabs/KnpMenu/graphs/contributors). [3]: https://github.com/derrabus [4]: https://github.com/garak [5]: https://github.com/stof + diff --git a/doc/01-Basic-Menus.md b/doc/01-Basic-Menus.md index fc26c0b0..9d974d72 100644 --- a/doc/01-Basic-Menus.md +++ b/doc/01-Basic-Menus.md @@ -1,5 +1,4 @@ -Creating Menus: The Basics -========================== +# Creating Menus: The Basics Let's face it, creating menus sucks. Menus - a common aspect of any site - can range from being simple and mundane to giant monsters that @@ -9,8 +8,7 @@ This bundle solves the issue by giving you a small, yet powerful and flexible framework for handling your menus. While most of the examples shown here are simple, the menus can grow arbitrarily large and deep. -Creating a menu ---------------- +## Creating a menu The menu framework centers around one main interface: `Knp\Menu\ItemInterface`. Items are created by a factory implementing `Knp\Menu\FactoryInterface`. @@ -29,7 +27,7 @@ $factory = new MenuFactory(); $menu = $factory->createItem('My menu'); $menu->addChild('Home', ['uri' => '/']); $menu->addChild('Comments', ['uri' => '#comments']); -$menu->addChild('Symfony', ['uri' => 'http://symfony.com/']); +$menu->addChild('Symfony', ['uri' => 'https://symfony.com/']); $renderer = new ListRenderer(new Matcher()); echo $renderer->render($menu); @@ -46,7 +44,7 @@ The above would render the following html code: Comments
  • - Symfony + Symfony
  • ``` @@ -54,13 +52,13 @@ The above would render the following html code: >**NOTE** >The menu framework automatically adds `first` and `last` classes to each >`
  • ` tag at each level for easy styling. Notice also that a `current` ->class is added to the "current" menu item by uri and `current_ancestor` +>class is added to the "current" menu item by URI and `current_ancestor` >to its ancestors (the classes are configurable) The above example assumes >the menu is being rendered on the `/comments` page, making the Comments >menu the "current" item. When the menu is rendered, it's actually spaced correctly so that it appears -as shown in the source html. This is to allow for easier debugging and can +as shown in the source HTML. This is to allow for easier debugging and can be turned off by passing the `true` as the second argument to the renderer. ```php @@ -88,8 +86,7 @@ Note: You can customize the rendering by extending the `ListRenderer` and overwrite some of its methods. If you use the [TwigRenderer](02-Twig-Integration.md), you can overwrite templates. Or you can provide your own implementation of the `RendererInterface`. -Working with your menu tree ---------------------------- +## Working with your menu tree Your menu tree works and acts like a multidimensional array. Specifically, it implements ArrayAccess, Countable and Iterator: @@ -122,8 +119,7 @@ when creating it is the name you'll use when accessing it. By default, the name is also used when displaying the menu, but that can be overridden by setting the menu item's label (see below). -Customizing each menu item --------------------------- +## Customizing each menu item There are many ways to customize the output of each menu item. Each property can be customized in two ways: either by passing it as an option when creating @@ -143,18 +139,18 @@ $menu->addChild('Home', ['uri' => '/', 'label' => 'Back to homepage']); $menu['Home']->setLabel('Back to homepage'); ``` -### The uri +### The URI -If an item isn't given a url, then text will be output instead of a link: +If an item isn't given a URL, then text will be output instead of a link: ```php addChild('Not a link'); $menu->addChild('Home', '/'); -$menu->addChild('Symfony', 'http://www.symfony-reloaded.org'); +$menu->addChild('Symfony', 'https://www.symfony-reloaded.org'); ``` -You can also specify the uri after creation via the `setUri()` method: +You can also specify the URI after creation via the `setUri()` method: ```php setUri('/'); ``` >**NOTE** ->If you want to remove the uri of an item, set it to `null`. +>If you want to remove the URI of an item, set it to `null`. ### Menu attributes @@ -188,7 +184,7 @@ children attributes (rendered on the `