@@ -41,18 +41,21 @@ object Source {
4141 /** Creates a Source instance from a single character.
4242 *
4343 * @param c the character to use as the source content
44+ * @return a `Source` that yields the single character `c`
4445 */
4546 def fromChar (c : Char ): Source = fromIterable(Array (c))
4647
4748 /** Creates Source from array of characters, with empty description.
4849 *
4950 * @param chars the array of characters to use as the source content
51+ * @return a `Source` that yields the characters from `chars`
5052 */
5153 def fromChars (chars : Array [Char ]): Source = fromIterable(chars)
5254
5355 /** Creates Source from a String, with no description.
5456 *
5557 * @param s the string to use as the source content
58+ * @return a `Source` that yields the characters of `s`
5659 */
5760 def fromString (s : String ): Source = fromIterable(s)
5861
@@ -61,6 +64,7 @@ object Source {
6164 *
6265 * @param name the name of the file to read
6366 * @param codec the implicit codec used for character encoding
67+ * @return a `BufferedSource` reading from the named file, described by its filename
6468 */
6569 def fromFile (name : String )(implicit codec : Codec ): BufferedSource =
6670 fromFile(new JFile (name))(using codec)
@@ -70,6 +74,7 @@ object Source {
7074 *
7175 * @param name the name of the file to read
7276 * @param enc the name of the character encoding to use
77+ * @return a `BufferedSource` reading from the named file with the given encoding
7378 */
7479 def fromFile (name : String , enc : String ): BufferedSource =
7580 fromFile(name)(using Codec (enc))
@@ -78,6 +83,7 @@ object Source {
7883 *
7984 * @param uri the file URI to read from
8085 * @param codec the implicit codec used for character encoding
86+ * @return a `BufferedSource` reading from the file referenced by `uri`
8187 */
8288 def fromFile (uri : URI )(implicit codec : Codec ): BufferedSource =
8389 fromFile(new JFile (uri))(using codec)
@@ -86,6 +92,7 @@ object Source {
8692 *
8793 * @param uri the file URI to read from
8894 * @param enc the name of the character encoding to use
95+ * @return a `BufferedSource` reading from the file referenced by `uri` with the given encoding
8996 */
9097 def fromFile (uri : URI , enc : String ): BufferedSource =
9198 fromFile(uri)(using Codec (enc))
@@ -95,6 +102,7 @@ object Source {
95102 *
96103 * @param file the file to read from
97104 * @param codec the implicit codec used for character encoding
105+ * @return a `BufferedSource` reading from `file` with the default buffer size
98106 */
99107 def fromFile (file : JFile )(implicit codec : Codec ): BufferedSource =
100108 fromFile(file, Source .DefaultBufSize )(using codec)
@@ -103,6 +111,7 @@ object Source {
103111 *
104112 * @param file the file to read from
105113 * @param enc the name of the character encoding to use
114+ * @return a `BufferedSource` reading from `file` with the given encoding
106115 */
107116 def fromFile (file : JFile , enc : String ): BufferedSource =
108117 fromFile(file)(using Codec (enc))
@@ -117,6 +126,7 @@ object Source {
117126 * @param file the file to read from
118127 * @param bufferSize the size of the input buffer, in characters
119128 * @param codec the implicit codec used for character encoding
129+ * @return a `BufferedSource` reading from `file` with the given buffer size, described by the file's absolute path
120130 */
121131 def fromFile (file : JFile , bufferSize : Int )(implicit codec : Codec ): BufferedSource = {
122132 val inputStream = new FileInputStream (file)
@@ -134,7 +144,7 @@ object Source {
134144 *
135145 * @param bytes the array of bytes to decode into characters
136146 * @param codec the implicit codec used for character encoding
137- * @return the created `Source` instance.
147+ * @return a `Source` that yields the characters decoded from `bytes` using `codec`
138148 */
139149 def fromBytes (bytes : Array [Byte ])(implicit codec : Codec ): Source =
140150 fromString(new String (bytes, codec.name))
@@ -153,6 +163,7 @@ object Source {
153163 *
154164 * @param uri the file URI to read from
155165 * @param codec the implicit codec used for character encoding
166+ * @return a `BufferedSource` reading from the file referenced by `uri`
156167 */
157168 def fromURI (uri : URI )(implicit codec : Codec ): BufferedSource =
158169 fromFile(new JFile (uri))(using codec)
@@ -161,6 +172,7 @@ object Source {
161172 *
162173 * @param s the URL string to read from
163174 * @param enc the name of the character encoding to use
175+ * @return a `BufferedSource` reading from the URL given by `s` with the given encoding
164176 */
165177 def fromURL (s : String , enc : String ): BufferedSource =
166178 fromURL(s)(using Codec (enc))
@@ -169,6 +181,7 @@ object Source {
169181 *
170182 * @param s the URL string to read from
171183 * @param codec the implicit codec used for character encoding
184+ * @return a `BufferedSource` reading from the URL given by `s`
172185 */
173186 def fromURL (s : String )(implicit codec : Codec ): BufferedSource =
174187 fromURL(new URI (s).toURL)(using codec)
@@ -177,6 +190,7 @@ object Source {
177190 *
178191 * @param url the URL to read from
179192 * @param enc the name of the character encoding to use
193+ * @return a `BufferedSource` reading from the stream opened on `url` with the given encoding
180194 */
181195 def fromURL (url : URL , enc : String ): BufferedSource =
182196 fromURL(url)(using Codec (enc))
@@ -185,6 +199,7 @@ object Source {
185199 *
186200 * @param url the URL to read from
187201 * @param codec the implicit codec used for character encoding
202+ * @return a `BufferedSource` reading from the stream opened on `url`
188203 */
189204 def fromURL (url : URL )(implicit codec : Codec ): BufferedSource =
190205 fromInputStream(url.openStream())(using codec)
@@ -197,7 +212,7 @@ object Source {
197212 * @param reset a () => Source which resets the stream (if unset, reset() will throw an Exception)
198213 * @param close a () => Unit method which closes the stream (if unset, close() will do nothing)
199214 * @param codec (implicit) a scala.io.Codec specifying behavior (defaults to Codec.default)
200- * @return the buffered source
215+ * @return a `BufferedSource` reading from `inputStream` with the given buffer size
201216 */
202217 def createBufferedSource (
203218 inputStream : InputStream ,
@@ -221,6 +236,7 @@ object Source {
221236 *
222237 * @param resource name of the resource to load from the classpath
223238 * @param classLoader classloader to be used, or context classloader if not specified
239+ * @param codec the implicit codec used for character encoding
224240 * @return the buffered source
225241 */
226242 def fromResource (resource : String , classLoader : ClassLoader = Thread .currentThread().getContextClassLoader())(implicit codec : Codec ): BufferedSource =
@@ -406,6 +422,7 @@ abstract class Source extends Iterator[Char] with Closeable {
406422 /** Change or disable the positioner.
407423 *
408424 * @param on whether to enable (`true`) or disable (`false`) position tracking
425+ * @return this `Source`, to allow chained configuration calls
409426 */
410427 def withPositioning (on : Boolean ): this .type = {
411428 positioner = if (on) RelaxedPositioner else NoPositioner
0 commit comments