Skip to content

Commit

Permalink
fix(generator): consistent javadoc code block layout
Browse files Browse the repository at this point in the history
By swapping code/pre and inserting a leading line break, javadoc code blocks now look nice in the Java source and render correctly in both the IDE and browser.
  • Loading branch information
Spasi committed May 15, 2017
1 parent c3e5ea3 commit ec09a19
Show file tree
Hide file tree
Showing 52 changed files with 1,106 additions and 819 deletions.
1 change: 1 addition & 0 deletions doc/notes/3.1.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ This build includes the following changes:
- Vulkan: Function addresses are now retrieved only once, using the optimal method for each function type.
* This avoids warnings on pedantic validation layers.
- Fixed callback invocation bugs on 32-bit architectures.
- Fixed various javadoc formatting issues (#308)

### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package org.lwjgl.generator
import java.lang.Math.*

private val REDUNDANT_WHITESPACE = "^[ \\t]+$".toRegex(RegexOption.MULTILINE)
private val BLOCK_NODE = "(?:div|h[1-6]|pre|table|thead|tfoot|tbody|td|tr|ul|li|ol|dl|dt|dd)" // TODO: add more here if necessary
private val BLOCK_NODE = "(?:div|h[1-6]|code|table|thead|tfoot|tbody|td|tr|ul|li|ol|dl|dt|dd)" // TODO: add more here if necessary
private val FRAGMENT = "(</?$BLOCK_NODE(?:\\s[^>]+)?>|^)([\\s\\S]*?)(?=</?$BLOCK_NODE(?:\\s[^>]+)?>|$)".toRegex()
private val CHILD_NODE = "<(?:tr|thead|tfoot|tbody|li|dt|dd)>".toRegex()
private val PARAGRAPH_PATTERN = "\\n\\n(?:\\n?[ \\t]*[\\S][^\\n]*)+".toRegex(RegexOption.MULTILINE)
Expand Down Expand Up @@ -314,12 +314,12 @@ private val CODE_BLOCK_ESCAPE_PATTERN = "^".toRegex(RegexOption.MULTILINE) // li
private val CODE_BLOCK_TAB_PATTERN = "\t".toRegex() // tabs

/** Useful for pre-formatted code blocks. */
fun codeBlock(code: String) = """<pre><code>
fun codeBlock(code: String) = """<code><pre>
${code
.replace(CODE_BLOCK_TRIM_PATTERN, "") // ...trim
.replace(CODE_BLOCK_ESCAPE_PATTERN, "\uFFFF") // ...escape
.replace(CODE_BLOCK_TAB_PATTERN, " ") // ...replace with 4 spaces for consistent formatting.
}</code></pre>"""
}</pre></code>"""

fun note(content: String) = "<div style=\"margin-left: 26px; border-left: 1px solid gray; padding-left: 14px;\"><h5>Note</h5>\n$content</div>"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,12 @@ val aiMaterialProperty_pp = struct(ASSIMP_PACKAGE, "AIMaterialProperty", nativeN
Material property names follow a simple scheme:
${codeBlock("""
$<name>
?<name>
$&lt;name&gt;
?&lt;name&gt;
A public property, there must be corresponding AI_MATKEY_XXX define
2nd: Public, but ignored by the aiProcess_RemoveRedundantMaterials
post-processing step.
~<name>
~&lt;name&gt;
A temporary property for internal use.
""")}
"""
Expand Down
57 changes: 0 additions & 57 deletions modules/templates/src/main/kotlin/org/lwjgl/glfw/templates/GLFW.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2488,63 +2488,6 @@ val GLFW = "GLFW".nativeClass(packageName = GLFW_PACKAGE, prefix = "GLFW", bindi
since = "version 2.2"
)

/*! @brief Returns the state of all hats of the specified joystick.
*
* This function returns the state of all hats of the specified joystick.
* Each element in the array is one of the following values:
*
* Name | Value
* --------------------- | --------------------------------
* `GLFW_HAT_CENTERED` | 0
* `GLFW_HAT_UP` | 1
* `GLFW_HAT_RIGHT` | 2
* `GLFW_HAT_DOWN` | 4
* `GLFW_HAT_LEFT` | 8
* `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
* `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
* `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
* `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
*
* The diagonal directions are bitwise combinations of the primary (up, right,
* down and left) directions and you can test for these individually by ANDing
* it with the corresponding direction.
*
* @code
* if (hats[2] & GLFW_HAT_RIGHT)
* {
* // State of hat 2 could be right-up, right or right-down
* }
* @endcode
*
* Querying a joystick ID with no device present is not an error, but will
* cause this function to return `NULL`. Call @ref glfwJoystickPresent to
* check device presence.
*
* @param[in] jid The [joystick](@ref joysticks) to query.
* @param[out] count Where to store the number of hat states in the returned
* array. This is set to zero if the joystick is not present or an error
* occurred.
* @return An array of hat states, or `NULL` if the joystick is not present
* or an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
*
* @bug @linux Joystick hats are currently unimplemented.
*
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
* should not free it yourself. It is valid until the specified joystick is
* disconnected, this function is called again for that joystick or the library
* is terminated.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref joystick_hat
*
* @since Added in version 3.3.
*
* @ingroup input
*/
const..unsigned_char_p(
"GetJoystickHats",
"""
Expand Down
Loading

0 comments on commit ec09a19

Please sign in to comment.