Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added links into appendix #665

Merged
merged 5 commits into from
Dec 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ data class RuleDescription(val ruleName: String,
/**
* Remove square brackets from code style
*/
val correctCodeStyle = codeStyle.substring(codeStyle.indexOf("[") + 1, codeStyle.indexOf("]"))
val correctCodeStyle = codeStyle.substring(codeStyle.indexOf("[") + 1, codeStyle.indexOf("]")).run {
"\\hyperref[sec:$this]{$this}"
}

/**
* Replace space between words with underline for Latex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ fun generateCodeStyle(guideDir: File, wpDir: File) {
2 -> writer.writeln("""\subsubsection*{\textbf{$name}}${"\n"}\leavevmode\newline""")
else -> {}
}
writer.writeln("\\label{sec:${name.getFirstNumber()}}")

continue
}
if (iterator.hasNext() && line.trim().startsWith("```")) {
Expand Down Expand Up @@ -150,7 +152,7 @@ fun generateCodeStyle(guideDir: File, wpDir: File) {

private fun writeTableContentLine(writer: PrintWriter, line: String, numbOfSpaces: Double) {
writer.write("\\hspace{${numbOfSpaces}cm}")
writer.writeln(line
val correctLine = line
.trim()
.replace("[", "")
.replace("]", "")
Expand All @@ -159,7 +161,7 @@ private fun writeTableContentLine(writer: PrintWriter, line: String, numbOfSpace
.replace("_", "\\_")
.replace("#", "\\#")
.replace("&", "\\&")
)
writer.writeln("\\hyperref[sec:${correctLine.getFirstNumber()}]{$correctLine}")
}

/**
Expand Down Expand Up @@ -220,3 +222,5 @@ private fun findBoldOrItalicText(regex: Regex,
}
return correctedLine
}

private fun String.getFirstNumber() = trimStart().takeWhile { it.isDigit() || it == '.' }
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.io.PrintWriter
@Suppress("VARIABLE_NAME_INCORRECT_FORMAT")
val NUMBER_IN_TAG = Regex("\"([a-z0-9.]*)\"") // finds "r1.0.2"
@Suppress("VARIABLE_NAME_INCORRECT_FORMAT")
val RULE_NAME = Regex("(</a>[A-Za-z 0-9.-]*)") // get's rule name from ### <a>...</a> Rule name
val RULE_NAME = Regex("(</a>[A-Za-z 0-9'.-]*)") // get's rule name from ### <a>...</a> Rule name
kentr0w marked this conversation as resolved.
Show resolved Hide resolved
@Suppress("VARIABLE_NAME_INCORRECT_FORMAT")
val BOLD_TEXT = Regex("""\*\*([^*]+)\*\*""") // finds bold text in regular lines
@Suppress("VARIABLE_NAME_INCORRECT_FORMAT")
Expand Down
4 changes: 2 additions & 2 deletions info/guide/diktat-coding-convention.md
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ val myVariable = emptyMap<Int, String>()
val myVariable: Map<Int, String> = emptyMap()
```

#### <a name="r4.3.3"></a> Null-safety
#### <a name="r4.3.3"></a> 4.3.3 Null-safety

Try to avoid explicit null checks (explicit comparison with `null`)
Kotlin is declared as [Null-safe](https://kotlinlang.org/docs/reference/null-safety.html) language.
Expand Down Expand Up @@ -1864,7 +1864,7 @@ Each nesting level will increase the amount of effort needed to read the code be
Functional decomposition should be implemented to avoid confusion for the developer who reads the code.
This will help the reader switch between contexts.

#### <a name="r5.1.3"></a> Rule 5.1.3 Avoid using nested functions
#### <a name="r5.1.3"></a> 5.1.3 Avoid using nested functions
Nested functions create a more complex function context, thereby confusing readers.
With nested functions, the visibility context may not be evident to the code reader.

Expand Down
2 changes: 1 addition & 1 deletion info/guide/guide-chapter-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ val myVariable = emptyMap<Int, String>()
val myVariable: Map<Int, String> = emptyMap()
```

#### <a name="r4.3.3"></a> Null-safety
#### <a name="r4.3.3"></a> 4.3.3 Null-safety

Try to avoid explicit null checks (explicit comparison with `null`)
Kotlin is declared as [Null-safe](https://kotlinlang.org/docs/reference/null-safety.html) language.
Expand Down
2 changes: 1 addition & 1 deletion info/guide/guide-chapter-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Each nesting level will increase the amount of effort needed to read the code be
Functional decomposition should be implemented to avoid confusion for the developer who reads the code.
This will help the reader switch between contexts.

#### <a name="r5.1.3"></a> Rule 5.1.3 Avoid using nested functions
#### <a name="r5.1.3"></a> 5.1.3 Avoid using nested functions
Nested functions create a more complex function context, thereby confusing readers.
With nested functions, the visibility context may not be evident to the code reader.

Expand Down
Loading