Skip to content

Commit 7f858b3

Browse files
Added documentation for supported feed formats with XML and JSON examples
1 parent d35cbcf commit 7f858b3

File tree

6 files changed

+106
-4
lines changed

6 files changed

+106
-4
lines changed

docs/labels.list

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE labels SYSTEM "https://resources.jetbrains.com/writerside/1.0/labels-list.dtd">
3+
<labels xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/labels.xsd"
5+
>
6+
<secondary-label id="format-xml" name="xml" color="purple">
7+
Available for XML feeds
8+
</secondary-label>
9+
10+
<secondary-label id="format-json" name="json" color="strawberry">
11+
Available for JSON feeds
12+
</secondary-label>
13+
14+
</labels>

docs/laravel-feeds.tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<toc-element toc-title="License" topic="license.topic" />
1313
</toc-element>
1414
<toc-element topic="introduction.topic">
15+
<toc-element topic="supported-formats.topic" />
1516
<toc-element topic="installation.topic" />
1617
<toc-element topic="create-feeds.topic" />
1718
<toc-element topic="generation.topic">
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Feeds;
6+
7+
use App\Models\User;
8+
use DragonCode\LaravelFeed\Enums\FeedFormatEnum;
9+
use DragonCode\LaravelFeed\Feeds\Feed;
10+
use Illuminate\Database\Eloquent\Builder;
11+
12+
class UserFeed extends Feed
13+
{
14+
protected FeedFormatEnum $format = FeedFormatEnum::Json;
15+
16+
public function builder(): Builder
17+
{
18+
//
19+
}
20+
}

docs/topics/advanced-usage.topic

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@
1212

1313
<show-structure depth="3" />
1414

15-
<note>
16-
<p>
17-
<format style="bold">Reserved directives:</format>
18-
</p>
15+
<note title="Reserved directives">
1916
<list>
2017
<li><a href="#_attributes" /></li>
2118
<li><a href="#_value" /></li>
2219
<li><a href="#_cdata" /></li>
2320
<li><a href="#_mixed" /></li>
2421
<li><a href="#_custom" /></li>
2522
</list>
23+
24+
<p>
25+
The use of directives is available only when generating feeds in the XML format.
26+
</p>
2627
</note>
2728

2829
<chapter title="Elements" id="elements">
2930
<chapter title="Root element" id="root_element">
31+
<secondary-label ref="format-xml" />
32+
<secondary-label ref="format-json" />
33+
3034
<tip>
3135
<p>
3236
By default, the name of the root element is derived from the base name of the feed class.
@@ -56,6 +60,9 @@
5660
</chapter>
5761

5862
<chapter title="Information" id="information">
63+
<secondary-label ref="format-xml" />
64+
<secondary-label ref="format-json" />
65+
5966
<p>
6067
To add information to the beginning of the root element (if present) or without it,
6168
override the
@@ -87,6 +94,9 @@
8794
</chapter>
8895

8996
<chapter title="Header &amp; footer" id="header_and_footer">
97+
<secondary-label ref="format-xml" />
98+
<secondary-label ref="format-json" />
99+
90100
<p>
91101
To change the header and footer, override the <code>header</code> and <code>footer</code> methods:
92102
</p>
@@ -101,6 +111,8 @@
101111
</chapter>
102112

103113
<chapter title="Attributes" id="attributes">
114+
<secondary-label ref="format-xml" />
115+
104116
<code-block lang="php" src="advanced-element-attribute.php" include-lines="5-" />
105117
<code-block lang="php" src="advanced-element-attribute-item.php" include-lines="5-" />
106118

@@ -114,6 +126,8 @@
114126

115127
<chapter title="Directives" id="directives">
116128
<chapter title="@attributes" id="_attributes">
129+
<secondary-label ref="format-xml" />
130+
117131
<link-summary>Indicates an array of attributes</link-summary>
118132

119133
<p>
@@ -132,6 +146,8 @@
132146
</chapter>
133147

134148
<chapter title="@value" id="_value">
149+
<secondary-label ref="format-xml" />
150+
135151
<link-summary>Indicates the applicable value "as it is"</link-summary>
136152

137153
<tip>
@@ -152,6 +168,8 @@
152168
</chapter>
153169

154170
<chapter title="@cdata" id="_cdata">
171+
<secondary-label ref="format-xml" />
172+
155173
<link-summary>Allows the use of XML markup without transformation</link-summary>
156174

157175
<tip>
@@ -173,6 +191,8 @@
173191
</chapter>
174192

175193
<chapter title="@mixed" id="_mixed">
194+
<secondary-label ref="format-xml" />
195+
176196
<link-summary>Allows you to use XML markup directly within the structure of the document</link-summary>
177197

178198
<p>
@@ -189,6 +209,8 @@
189209
</chapter>
190210

191211
<chapter title="@custom" id="_custom">
212+
<secondary-label ref="format-xml" />
213+
192214
<link-summary>Describes the possibility of listing an array of elements with the same keys</link-summary>
193215

194216
<p>

docs/topics/create-feeds.topic

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,24 @@
100100
</chapter>
101101
</chapter>
102102

103+
<chapter title="File format" id="file_format">
104+
<note title="Supported formats">
105+
<include from="supported-formats.topic" element-id="formats" />
106+
</note>
107+
108+
<p>
109+
You can generate feeds in different formats.
110+
A feed class can be correctly exported only to the format for which it is intended.
111+
This is due to the use of
112+
<a href="advanced-usage.topic#directives">directives</a> and other format specifics.
113+
</p>
114+
115+
<p>
116+
To apply the required format, simply override the <code>$format</code> property in the feed class:
117+
</p>
118+
119+
<code-block lang="php" src="create-feeds-feed-format.php" include-lines="5-" />
120+
121+
</chapter>
122+
103123
</topic>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE topic
3+
SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd">
4+
<topic
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
7+
title="Supported formats" id="supported-formats" help-id="supported-formats">
8+
9+
<link-summary>List of supported feed export formats</link-summary>
10+
<card-summary>List of supported feed export formats</card-summary>
11+
<web-summary>List of supported feed export formats</web-summary>
12+
13+
<show-structure depth="3" />
14+
15+
<snippet id="formats">
16+
<list>
17+
<li>xml</li>
18+
<li>json</li>
19+
</list>
20+
21+
<p>
22+
By default, the <code>xml</code> format is used.
23+
</p>
24+
</snippet>
25+
</topic>

0 commit comments

Comments
 (0)