Skip to content
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

Fix headings #427

Merged
merged 2 commits into from
Oct 1, 2024
Merged
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
30 changes: 3 additions & 27 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,6 @@ on:
- docs/**

jobs:
validate-with-guides:
name: "Validate documentation with phpDocumentor/guides"
runs-on: "ubuntu-22.04"

steps:
- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.2"

- name: "Remove existing composer file"
run: "rm composer.json"

- name: "Require phpdocumentor/guides-cli"
run: "composer require --dev phpdocumentor/guides-cli --no-update"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "highest"

- name: "Run guides-cli"
run: "vendor/bin/guides -vvv --no-progress --fail-on-log docs/en"
documentation:
name: "Documentation"
uses: "doctrine/.github/.github/workflows/[email protected]"
63 changes: 33 additions & 30 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Getting Started
===============

Introduction
============
------------

Doctrine Collections is a library that contains classes for working with
arrays of data. Here is an example using the simple
Expand All @@ -17,7 +20,7 @@ arrays of data. Here is an example using the simple
}); // [2, 3]

Collection Methods
==================
------------------

Doctrine Collections provides an interface named ``Doctrine\Common\Collections\Collection``
that resembles the nature of a regular PHP array. That is,
Expand All @@ -40,23 +43,23 @@ from the ``Doctrine\Common\Collections\ReadableCollection`` interface.
The methods available on the interface are:

add
---
^^^

Adds an element at the end of the collection.

.. code-block:: php
$collection->add('test');

clear
-----
^^^^^

Clears the collection, removing all elements.

.. code-block:: php
$collection->clear();

contains
--------
^^^^^^^^

Checks whether an element is contained in the collection. This is an O(n) operation, where n is the size of the collection.

Expand All @@ -66,7 +69,7 @@ Checks whether an element is contained in the collection. This is an O(n) operat
$contains = $collection->contains('test'); // true

containsKey
-----------
^^^^^^^^^^^

Checks whether the collection contains an element with the specified key/index.

Expand All @@ -76,7 +79,7 @@ Checks whether the collection contains an element with the specified key/index.
$contains = $collection->containsKey('test'); // true

current
-------
^^^^^^^

Gets the element of the collection at the current iterator position.

Expand All @@ -86,7 +89,7 @@ Gets the element of the collection at the current iterator position.
$current = $collection->current(); // first

get
---
^^^

Gets the element at the specified key/index.

Expand All @@ -98,7 +101,7 @@ Gets the element at the specified key/index.
$value = $collection->get('key'); // value

getKeys
-------
^^^^^^^

Gets all keys/indices of the collection.

Expand All @@ -108,7 +111,7 @@ Gets all keys/indices of the collection.
$keys = $collection->getKeys(); // [0, 1, 2]

getValues
---------
^^^^^^^^^

Gets all values of the collection.

Expand All @@ -122,7 +125,7 @@ Gets all values of the collection.
$values = $collection->getValues(); // ['value1', 'value2', 'value3']

isEmpty
-------
^^^^^^^

Checks whether the collection is empty (contains no elements).

Expand All @@ -132,7 +135,7 @@ Checks whether the collection is empty (contains no elements).
$isEmpty = $collection->isEmpty(); // false

first
-----
^^^^^

Sets the internal iterator to the first element in the collection and returns this element.

Expand All @@ -142,7 +145,7 @@ Sets the internal iterator to the first element in the collection and returns th
$first = $collection->first(); // first

exists
------
^^^^^^

Tests for the existence of an element that satisfies the given predicate.

Expand All @@ -154,7 +157,7 @@ Tests for the existence of an element that satisfies the given predicate.
}); // true

findFirst
---------
^^^^^^^^^

Returns the first element of this collection that satisfies the given predicate.

Expand All @@ -166,7 +169,7 @@ Returns the first element of this collection that satisfies the given predicate.
}); // 3

filter
------
^^^^^^

Returns all the elements of this collection for which your callback function returns `true`.
The order and keys of the elements are preserved.
Expand All @@ -179,7 +182,7 @@ The order and keys of the elements are preserved.
}); // [2, 3]

forAll
------
^^^^^^

Tests whether the given predicate holds for all elements of this collection.

Expand All @@ -191,7 +194,7 @@ Tests whether the given predicate holds for all elements of this collection.
}); // false

indexOf
-------
^^^^^^^

Gets the index/key of a given element. The comparison of two elements is strict, that means not only the value but also the type must match. For objects this means reference equality.

Expand All @@ -201,7 +204,7 @@ Gets the index/key of a given element. The comparison of two elements is strict,
$indexOf = $collection->indexOf(3); // 2

key
---
^^^

Gets the key/index of the element at the current iterator position.

Expand All @@ -213,7 +216,7 @@ Gets the key/index of the element at the current iterator position.
$key = $collection->key(); // 1

last
----
^^^^

Sets the internal iterator to the last element in the collection and returns this element.

Expand All @@ -223,7 +226,7 @@ Sets the internal iterator to the last element in the collection and returns thi
$last = $collection->last(); // 3

map
---
^^^

Applies the given function to each element in the collection and returns a new collection with the elements returned by the function.

Expand All @@ -235,7 +238,7 @@ Applies the given function to each element in the collection and returns a new c
}); // [2, 3, 4]

reduce
------
^^^^^^

Applies iteratively the given function to each element in the collection, so as to reduce the collection to a single value.

Expand All @@ -247,7 +250,7 @@ Applies iteratively the given function to each element in the collection, so as
}, 0); // 6

next
----
^^^^

Moves the internal iterator position to the next element and returns this element.

Expand All @@ -257,7 +260,7 @@ Moves the internal iterator position to the next element and returns this elemen
$next = $collection->next(); // 2

partition
---------
^^^^^^^^^

Partitions this collection in two collections according to a predicate. Keys are preserved in the resulting collections.

Expand All @@ -269,7 +272,7 @@ Partitions this collection in two collections according to a predicate. Keys are
}); // [[2, 3], [1]]

remove
------
^^^^^^

Removes the element at the specified index from the collection.

Expand All @@ -279,7 +282,7 @@ Removes the element at the specified index from the collection.
$collection->remove(0); // [2, 3]

removeElement
-------------
^^^^^^^^^^^^^

Removes the specified element from the collection, if it is found.

Expand All @@ -289,7 +292,7 @@ Removes the specified element from the collection, if it is found.
$collection->removeElement(3); // [1, 2]

set
---
^^^

Sets an element in the collection at the specified key/index.

Expand All @@ -299,7 +302,7 @@ Sets an element in the collection at the specified key/index.
$collection->set('name', 'jwage');

slice
-----
^^^^^

Extracts a slice of $length elements starting at position $offset from the Collection. If $length is null it returns all elements from $offset to the end of the Collection. Keys have to be preserved by this method. Calling this method will only return the selected slice and NOT change the elements contained in the collection slice is called on.

Expand All @@ -309,7 +312,7 @@ Extracts a slice of $length elements starting at position $offset from the Colle
$slice = $collection->slice(1, 2); // [1, 2]

toArray
-------
^^^^^^^

Gets a native PHP array representation of the collection.

Expand All @@ -319,7 +322,7 @@ Gets a native PHP array representation of the collection.
$array = $collection->toArray(); // [0, 1, 2, 3, 4, 5]

Selectable Methods
==================
------------------

Some Doctrine Collections, like ``Doctrine\Common\Collections\ArrayCollection``,
implement an interface named ``Doctrine\Common\Collections\Selectable``
Expand All @@ -328,7 +331,7 @@ can be applied to a collection to get a result with matching elements
only.

matching
--------
^^^^^^^^

Selects all elements from a selectable that match the expression and
returns a new collection containing these elements and preserved keys.
Expand Down