Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
theEvilReaper committed Jan 10, 2024
1 parent 9c6e067 commit 227fef9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/kotlin/net/theevilreaper/dartpoet/DartFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ class DartFile internal constructor(
}
}


/**
* Writes the content from a [DartFile] to the given [Appendable].
* @param out the [Appendable] where the content should be written
* @throws IOException if the content can't be written
*/
@Throws(IOException::class)
fun write(out: Appendable) {
val codeWriter = CodeWriter(
Expand All @@ -74,6 +78,11 @@ class DartFile internal constructor(
codeWriter.close()
}

/**
* Writes the content from a [DartFile] to the given [Path].
* @param path the path where the file should be written
* @throws IOException if the file can't be written
*/
@Throws(IOException::class)
fun write(path: Path) {
require(Files.notExists(path) || Files.isDirectory(path)) {
Expand Down Expand Up @@ -114,6 +123,9 @@ class DartFile internal constructor(
return builder
}

/**
* Creates a new instance of [DartFileBuilder] with the specified name.
*/
companion object {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import net.theevilreaper.dartpoet.annotation.AnnotationSpec
import net.theevilreaper.dartpoet.code.CodeWriter
import net.theevilreaper.dartpoet.code.writer.PropertyWriter
import net.theevilreaper.dartpoet.code.buildCodeString
import net.theevilreaper.dartpoet.property.consts.ConstantPropertyBuilder
import net.theevilreaper.dartpoet.type.ClassName
import net.theevilreaper.dartpoet.type.TypeName
import net.theevilreaper.dartpoet.type.asTypeName
Expand Down Expand Up @@ -84,6 +85,9 @@ class PropertySpec(
return builder
}

/**
* The companion object contains some helper methods to create a new instance from the [PropertyBuilder].
*/
companion object {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import kotlin.reflect.KClass

/**
* A class representing a custom type named [ClassName].
* It can be used to model class names, interface names, typedef names, and enum names which are not built-in types.
*
* @param name the name of the [ClassName]
* @param isNullable a flag indicating whether the [ClassName] can be null (default is false).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class ParameterizedTypeName internal constructor(
return out
}

/**
* Returns a copy of this [ParameterizedTypeName] with the provided type arguments.
*/
companion object {

/**
Expand Down
11 changes: 11 additions & 0 deletions src/main/kotlin/net/theevilreaper/dartpoet/type/TypeNames.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package net.theevilreaper.dartpoet.type

/**
* The file contains some common used [ClassName] instances which are used in the library.
* It contains only the primitive types which are supported by Dart.
* @since 1.0.0
*/

// Represents the boolean type in Dart
@JvmField
val BOOLEAN: ClassName = ClassName("bool")

// Represents the integer type in Dart
@JvmField
val INTEGER: ClassName = ClassName("int")

// Represents the double type in Dart
@JvmField
val DOUBLE: ClassName = ClassName("double")

// Represents the string type in Dart
@JvmField
val STRING: ClassName = ClassName("String")

// Represents the dynamic type in Dart
@JvmField
val DYNAMIC: ClassName = DynamicClassName()

0 comments on commit 227fef9

Please sign in to comment.