Skip to content

Commit 3e8f558

Browse files
frayacgay
authored andcommitted
Docs: Edit 'file-system' module (dylan-lang#1510)
- Add graphviz extension to create a class hierarchy to file system, posix and microsoft locators. - Remove reference to 'file-stream' module. This paragraph was moved from module 'locators' and contained a reference to the module 'file-system', not needed now. - Rename key parameter 'filename'. The key parameter appears as 'filename' and in the documentation of the method as 'locator'. - To eliminate document duplication, I decided to address the issue in the paragraph discussing the 'make' method. Since it bears close resemblance to the method reference, I opted to remove the initial paragraph and provide a link to the reference instead. Additionally, I consolidated the documentation for the key parameters 'direction' and 'buffer-size' with a more comprehensive explanation.
1 parent df3b1f2 commit 3e8f558

File tree

2 files changed

+119
-47
lines changed

2 files changed

+119
-47
lines changed

documentation/library-reference/source/conf.py

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
sys.path.insert(0, os.path.abspath('../..'))
2121
from shared_sphinx_config import *
2222

23+
extensions = [
24+
'sphinx.ext.graphviz',
25+
'dylan.domain'
26+
]
2327

2428
# -- General configuration -----------------------------------------------------
2529

documentation/library-reference/source/system/file-system.rst

+115-47
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,70 @@ or a file within the file system.
9191
- :class:`<file-system-file-locator>`
9292
- :class:`<file-system-directory-locator>`
9393

94+
.. graphviz::
95+
:caption: File system locator class diagram. Dashed boxes are
96+
classes from module `locators`.
97+
98+
digraph G {
99+
fontname="Arial,sans-serif";
100+
node [shape=box, color=gray];
101+
102+
physical_locator [label="<physical-locator>\noa", style=dashed];
103+
file_locator [label="<file-locator>\noa", style=dashed];
104+
directory_locator [label="<directory-locator>\noa",style=dashed];
105+
file_system_locator [label="<file-system-locator>\noa", style=bold, color="#17594A"];
106+
file_system_file_locator [label="<file-system-file-locator>", style=bold, color="#17594A"];
107+
file_system_directory_locator [label="<file-system-directory-locator>", style=bold, color="#17594A"];
108+
109+
physical_locator -> file_system_locator;
110+
physical_locator -> directory_locator;
111+
physical_locator -> file_locator;
112+
file_system_locator -> file_system_file_locator;
113+
file_locator -> file_system_file_locator;
114+
file_system_locator -> file_system_directory_locator;
115+
directory_locator -> file_system_directory_locator;
116+
}
117+
94118
On Posix systems:
95119

96120
- :class:`<posix-file-system-locator>`
97121
- :class:`<posix-directory-locator>`
98122
- :class:`<posix-file-locator>`
99123

124+
.. graphviz::
125+
:caption: Posix file system hierarchy. Dashed boxes are classes
126+
from module `locators`.
127+
128+
digraph G {
129+
fontname="Arial,sans-serif";
130+
node [shape=box, color=gray];
131+
132+
physical_locator [label="<physical-locator>\noa", style=dashed] ;
133+
directory_locator [label="<directory-locator>\noa",style=dashed];
134+
135+
file_locator [label="<file-locator>\noa", style=dashed];
136+
file_system_locator [label="<file-system-locator>\noa"];
137+
file_system_file_locator [label="<file-system-file-locator>"];
138+
file_system_directory_locator [label="<file-system-directory-locator>"] ;
139+
140+
posix_file_system_locator [label="<posix-file-system-locator>\noas", style=bold, color="#17594A"];
141+
posix_directory_locator [label="<posix-directory-locator>\ns", style=bold, color="#17594A"] ;
142+
posix_file_locator [label="<posix-file-locator>\ns", style=bold, color="#17594A"]
143+
144+
physical_locator -> file_locator;
145+
physical_locator -> file_system_locator;
146+
physical_locator -> directory_locator;
147+
directory_locator -> file_system_directory_locator;
148+
file_locator -> file_system_file_locator;
149+
file_system_locator -> file_system_file_locator;
150+
file_system_locator -> file_system_directory_locator;
151+
file_system_locator -> posix_file_system_locator;
152+
file_system_directory_locator -> posix_directory_locator;
153+
file_system_file_locator -> posix_file_locator;
154+
posix_file_system_locator -> posix_directory_locator;
155+
posix_file_system_locator -> posix_file_locator;
156+
}
157+
100158
On Microsoft systems:
101159

102160
- :class:`<microsoft-server-locator>`
@@ -106,54 +164,61 @@ On Microsoft systems:
106164
- :class:`<microsoft-directory-locator>`
107165
- :class:`<microsoft-file-locator>`
108166

167+
.. graphviz::
168+
:caption: Microsoft file system hierarchy. Dashed boxes are classes
169+
from module `locators`.
170+
171+
digraph G {
172+
fontname="Arial,sans-serif";
173+
node [shape=box, color=gray];
174+
175+
locator [label="<locator>\noa",style=dashed];
176+
physical_locator [label="<physical-locator>\noa", style=dashed] ;
177+
directory_locator [label="<directory-locator>\noa",style=dashed];
178+
server_locator [label="<server-locator>\noa",style=dashed];
179+
180+
file_locator [label="<file-locator>\noa", style=dashed];
181+
file_system_locator [label="<file-system-locator>\noa"];
182+
183+
microsoft_file_system_locator [label="<microsoft-file-system-locator>\na", style=bold, color="#17594A"];
184+
microsoft_server_locator [label="<microsoft-server-locator>\nas", style=bold, color="#17594A"];
185+
microsoft_unc_locator [label="<microsoft-unc-locator>\ns", style=bold, color="#17594A"];
186+
microsoft_volume_locator [label="<microsoft-volume-locator>\ns", style=bold, color="#17594A"];
187+
microsoft_directory_locator [label="<microsoft-directory-locator>", style=bold, color="#17594A"];
188+
microsoft_file_locator [label="<microsoft-file-locator>", style=bold, color="#17594A"];
189+
190+
locator -> server_locator;
191+
locator -> physical_locator;
192+
physical_locator -> file_locator;
193+
physical_locator -> file_system_locator;
194+
physical_locator -> directory_locator;
195+
server_locator -> microsoft_server_locator;
196+
directory_locator -> microsoft_directory_locator;
197+
file_locator -> microsoft_file_locator;
198+
file_system_locator -> microsoft_file_system_locator;
199+
microsoft_file_system_locator -> microsoft_directory_locator;
200+
microsoft_file_system_locator -> microsoft_file_locator;
201+
microsoft_server_locator -> microsoft_unc_locator;
202+
microsoft_server_locator -> microsoft_volume_locator;
203+
}
204+
205+
109206
Native locators, which are bound to the host platform:
110207

111208
- :const:`<native-file-system-locator>`
112209

113210
File streams
114211
------------
115212

116-
File streams are intended only for accessing the contents of files. More
117-
general file handling facilities, such as renaming, deleting, moving, and
118-
parsing directory names, are provided by the :doc:`file-system
119-
</system/file-system>` module. The :drm:`make` method on :class:`<file-stream>`
120-
does not create direct instances of :class:`<file-stream>`, but instead an
121-
instance of a subclass determined by :gf:`type-for-file-stream`.
122-
123-
make *file-stream-class*
124-
125-
G.f method
126-
127-
make <file-stream> #key locator: direction: if-exists:
128-
if-does-not-exist: buffer-size: element-type:
129-
asynchronous?: share-mode => *file-stream-instance*
213+
File streams are intended only for accessing the contents of
214+
files. More general file handling facilities, such as renaming,
215+
deleting, moving, and parsing directory names, are provided by this
216+
module.
130217

131-
Creates and opens a stream over a file, and returns a new instance of a
132-
concrete subclass of :class:`<file-stream>` that streams over the
133-
contents of the file referenced by *filename*. To determine the concrete
134-
subclass to be instantiated, this method calls the generic function
135-
:gf:`type-for-file-stream`.
136-
137-
The ``locator:`` init-keyword should be a string naming a file. If the
138-
:doc:`Locators <../system/locators>` library is in use, *filename*
139-
should be an instance of :class:`<locator>` or a string that can be
140-
coerced to one.
141-
142-
The ``direction:`` init-keyword specifies the direction of the stream.
143-
This can be one of ``#"input"``, ``#"output"``, or ``#"input-output"``.
144-
The default is ``#"input"``.
145-
146-
The ``if-exists:`` and ``if-does-not-exist:`` init-keywords specify actions
147-
to take if the file named by *filename* does or does not already exist
148-
when the stream is created. These init-keywords are discussed in more
149-
detail in `Options when creating file streams`_.
150-
151-
The ``buffer-size:`` init-keyword can be used to suggest the size of a
152-
stream's buffer. See :class:`<buffered-stream>`.
153-
154-
The ``element-type:`` init-keyword specifies the type of the elements in
155-
the file named by *filename*. See `Options when creating file
156-
streams`_ for more details.
218+
The :drm:`make` method on :class:`<file-stream>` does not create
219+
direct instances of :class:`<file-stream>`, but instead an instance of
220+
a subclass determined by :gf:`type-for-file-stream`. See
221+
`make`_ and `Options when creating file streams`_ below.
157222

158223
Options when creating file streams
159224
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -854,6 +919,8 @@ File-System module.
854919
Repeatedly follows symbolic links starting with *file* until it finds a
855920
non-link file or directory, or a non-existent link target.
856921

922+
.. _make:
923+
857924
.. method:: make
858925
:specializer: <file-stream>
859926

@@ -862,7 +929,7 @@ File-System module.
862929
:signature: make *file-stream-class* #key *filename* *direction* *if-exists* *if-does-not-exist* *buffer-size* *element-type* => *file-stream-instance*
863930

864931
:parameter file-stream-class: The class :class:`<file-stream>`.
865-
:parameter #key filename: An instance of :drm:`<object>`.
932+
:parameter #key locator: An instance of :drm:`<object>`.
866933
:parameter #key direction: One of ``#"input"``, ``#"output"``, or
867934
``#"input-output"``. The default is ``#"input"``.
868935
:parameter #key if-exists: One of :drm:`#f`, ``#"new-version"``,
@@ -885,19 +952,20 @@ File-System module.
885952
instantiated, this method calls the generic function
886953
:gf:`type-for-file-stream`.
887954

888-
The *filename* init-keyword should be a string naming a file. If
889-
the :doc:`Locators <../system/locators>` library is in use,
890-
*filename* should be an instance of :class:`<locator>` or a string
891-
that can be coerced to one.
955+
The *locator* init-keyword should be a :class:`<file-locator>` or
956+
a :drm:`<string>` that can be coerced to one.
892957

893-
The *direction* init-keyword specifies the direction of the stream.
958+
The *direction* init-keyword specifies the direction of the
959+
stream. This can be one of ``#"input"``, ``#"output"``, or
960+
``#"input-output"``. The default is ``#"input"``.
894961

895962
The *if-exists* and *if-does-not-exist* init-keywords specify
896963
actions to take if the file named by *filename* does or does not
897964
already exist when the stream is created. These init-keywords are
898965
discussed in more detail in `Options when creating file streams`_.
899966

900-
The *buffer-size* init-keyword is explained in :class:`<buffered-stream>`.
967+
The *buffer-size* init-keyword can be used to suggest the size of
968+
a stream's buffer. See :class:`<buffered-stream>`.
901969

902970
The *element-type* init-keyword specifies the type of the elements
903971
in the file named by *filename*. This allows file elements to be

0 commit comments

Comments
 (0)