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

Configuration explorer cleanup #224

Open
wants to merge 179 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
25dbf61
Created projects structure
klein648 May 2, 2024
78305f9
Structure expanded
klein648 May 10, 2024
a240ef7
Added initial core for configuration explorer
klein648 Jun 9, 2024
e54f27b
Added configuration explorer to build.sbt
klein648 Jun 9, 2024
409c296
ce dependencies implemented into the sbt
klein648 Jun 13, 2024
9d58ebc
preparations for implementation of FileLocator
klein648 Jun 15, 2024
0376790
Implemented the ability to locate all configuration Files within the …
klein648 Jun 20, 2024
45050da
Code cleanup
klein648 Jun 20, 2024
44f2ce6
Searchfile() function now returns a List of the found files
klein648 Jun 20, 2024
87191ca
Code cleanup
klein648 Jun 20, 2024
d1793e9
Added more configuration files to file search
klein648 Jun 20, 2024
b1ee3c1
Added traits and case classes that represent the configs structure
klein648 Aug 13, 2024
28373cc
Implemented frame of comment object
klein648 Aug 24, 2024
50a2c16
Intermediate commit for comment parser
klein648 Aug 24, 2024
654bbe5
Intermediate commit for comment parser wrapper (unsure if I still nee…
klein648 Aug 24, 2024
b68c765
added empty line on print message
klein648 Aug 24, 2024
e5a8bb6
Added test method for file locator and test method for comment parser
klein648 Aug 24, 2024
8cafe86
switched order of config files
klein648 Aug 24, 2024
48b2b6d
created testfile for testing the comment parser
klein648 Aug 24, 2024
b7cb915
made parser skip to next line when a comment is found before an entry
klein648 Aug 24, 2024
40046bc
Implemented end condition for parseList
klein648 Aug 24, 2024
6c59f44
Housekeeping regarding the nextComment property
klein648 Aug 24, 2024
12a37a6
Implemented frame for parseObject method
klein648 Aug 24, 2024
23ffc6c
Fixed compilation error that occurred during refactoring
klein648 Aug 24, 2024
4e90fd1
Implemented correct flags for multi-line values
klein648 Sep 5, 2024
e6f5f53
FIX: ConfigList did not inherit from ConfigNode
klein648 Sep 5, 2024
152b25b
Implemented Config Object parse
klein648 Sep 5, 2024
8862c91
FIX: Compiler errors
klein648 Sep 5, 2024
7f733bc
FIX: runtime errors when parsing all projects configs
klein648 Sep 5, 2024
57287ce
Made toHTML and commitComments methods mandatory
klein648 Sep 11, 2024
3686739
Added comments and config for HTML components
klein648 Sep 11, 2024
98ecd87
FIX: fixed typo in comment flag
klein648 Sep 11, 2024
4f3cf42
Added Comments part 1
klein648 Sep 11, 2024
a0a45a5
Added template.html
klein648 Sep 12, 2024
8849360
Implemented toHTML() function
klein648 Sep 12, 2024
03b2b13
Removed commitComments() from configNode (not needed)
klein648 Sep 12, 2024
0c3171c
Exclude target paths as they produce duplicates
klein648 Sep 12, 2024
7b8b13b
Implemented HTML exporter
klein648 Sep 12, 2024
b781c3b
Changed title of template
klein648 Sep 12, 2024
f8c5560
Implemented export options for label and brief
klein648 Sep 12, 2024
05a5a03
Moved Path information of the config file into the comment label
klein648 Sep 12, 2024
8fe86d2
Moved Path information of the config file into the comment label
klein648 Sep 12, 2024
d40b07b
Implemented separated information for comments
klein648 Sep 12, 2024
1fe9b15
Fixed comments / added export setting
klein648 Sep 12, 2024
cd0df91
Implemented export to HTML
klein648 Sep 12, 2024
21637fb
FIX: The parser interpreted empty lines between comments as empty values
klein648 Sep 12, 2024
f75e4fa
FIX: Rename of the expandBox object has not been transferred to the J…
klein648 Sep 12, 2024
b5e710c
Feature: Empty config files are not shown on report
klein648 Sep 12, 2024
1a8d2d8
Removed placeholder comment
klein648 Sep 12, 2024
0e5bc74
Using codebrackets for properly displaying values
klein648 Sep 12, 2024
f35cbba
Changed comment spacing to pragraphs from double line breaks
klein648 Sep 12, 2024
35debad
Fixed view for html elements that are present in the config files
klein648 Sep 12, 2024
3ab2530
FIX: line remains were not transferred back after closing an object
klein648 Sep 12, 2024
b686a7a
Fixes recommended by IntelliJ
klein648 Sep 12, 2024
7af5f96
Greatly simplified commentParser by making it stateful
klein648 Sep 12, 2024
4320440
removed unnecessary print statement
klein648 Sep 12, 2024
a02e3b9
Added all missing config files
klein648 Sep 12, 2024
86841f8
FIX: Parser did not strip the "," separating two values in a list
klein648 Sep 12, 2024
a4e8f5b
removed testcases.conf as it was no valid HOCON
klein648 Sep 12, 2024
bfe3079
Cleaned up import statements
klein648 Sep 12, 2024
f2dd0f3
Added Comments
klein648 Sep 13, 2024
1115e03
Fixed Package naming
klein648 Sep 14, 2024
fba4654
Added:
klein648 Sep 30, 2024
a468b66
Code cleanup
klein648 Sep 30, 2024
60d40bf
More code cleanup
klein648 Sep 30, 2024
b9e1d94
Fixed parser crash that was implemented in cleanup
klein648 Oct 4, 2024
aab9aed
refactored filelocator for more general use
klein648 Oct 4, 2024
6347855
Removed non-opal configs from file filter
klein648 Oct 4, 2024
ee59120
Implemented merge for comments at collapse
klein648 Oct 4, 2024
fed7fa0
FIX: Merge Errors in comment
klein648 Oct 6, 2024
626d2a0
Refactored files to be ConfigObjects, fixed errors with expand
klein648 Oct 6, 2024
634e761
Removed t print (why was that here?)
klein648 Oct 6, 2024
8016830
Variable refactoring did not finish
klein648 Oct 6, 2024
594ae07
Mitigated risk of type error and added more infos in case two incompa…
klein648 Oct 6, 2024
ec8af86
Added label that represents the aggregated reference.conf
klein648 Oct 6, 2024
c0c65cb
Implemented a (sort of) Syntax Checker to the parsing process
klein648 Oct 6, 2024
3d725f7
Refactored parseComments to parseFile
klein648 Oct 6, 2024
a7de264
Fixed offset on key prints
klein648 Oct 6, 2024
f4d9239
- Added compatibility for root brackets and associated comments
klein648 Oct 6, 2024
89777d1
Added root brackets and config file level documentation
klein648 Oct 6, 2024
b5d8a63
Added dependency on bytecode representation
klein648 Oct 6, 2024
c81bc7b
FIX: Entries with comments, but without brief description did not rec…
klein648 Oct 6, 2024
4f45704
Added trim to object keys
klein648 Oct 10, 2024
1628121
Implemented alphabetical sorting for html output
klein648 Oct 10, 2024
f4e4307
Expanded doc function to include config documentation
klein648 Oct 11, 2024
448947d
FIX: Nested keys that ended up to be overlapping after expansion were…
klein648 Oct 11, 2024
afec964
FIX: Nested keys that ended up to be overlapping after expansion were…
klein648 Oct 11, 2024
f9d3ac5
Strips the double quotes from a key
klein648 Oct 11, 2024
cec7c5c
Strips the double quotes from a key
klein648 Oct 11, 2024
0c47cbf
Implemented Class replacement
klein648 Oct 11, 2024
a977256
Added toggle in config for class replacement
klein648 Oct 12, 2024
eb37679
Excluded test archives that end on .gz from the class replacing jar a…
klein648 Oct 13, 2024
c34c972
FIX: Comment Parser was not parsing the last line of a file
klein648 Oct 14, 2024
2cbee05
Code simplification
klein648 Oct 14, 2024
8f278c2
Enabled scalafmt
klein648 Oct 18, 2024
762174c
Managed IntelliJ commit issues
klein648 Oct 18, 2024
26e2b7b
Removed multi import
klein648 Oct 18, 2024
992321c
Added typesafe config cleanly to Dependencies
klein648 Oct 18, 2024
480eda1
Added comments
klein648 Oct 18, 2024
602bc0c
Added readme
klein648 Oct 18, 2024
1bf91eb
Added readme
klein648 Oct 18, 2024
5d488ce
Fixed missing question mark in readme
klein648 Oct 18, 2024
d275e22
Fixed scaladoc warnings
klein648 Oct 18, 2024
ec98273
Added dependenies and IntegrationTest configuration
klein648 Oct 18, 2024
f1a6c73
Added license disclaimers
klein648 Oct 18, 2024
339115f
Cleaned up duplicate. Added build version as system parameter for ce
klein648 Oct 19, 2024
0b0e629
Hands over Version build to ce
klein648 Oct 19, 2024
6707646
Fixed export paths
klein648 Oct 19, 2024
653df48
Fixed comments
klein648 Oct 19, 2024
ec6aa4b
Merge branch 'develop' into configuration_explorer_cleanup
klein648 Oct 20, 2024
f02cdb8
Fixed package import for comment
klein648 Oct 24, 2024
c8fcf05
Refactored comment to only contain the fully parsed comment
klein648 Oct 25, 2024
0784bbe
Replaced addOne() with +=
klein648 Oct 25, 2024
27730a6
Removed unnecessary this
klein648 Oct 26, 2024
4e316aa
restructured to change constraints to val
klein648 Oct 26, 2024
dd2c2d0
removed duplicate trims from comment
klein648 Oct 26, 2024
1a5ec3a
Added line breaks to html export to improve readability
klein648 Oct 26, 2024
e312230
Fixed odd case for none existing labels
klein648 Oct 26, 2024
efcb2f8
Avoid reading all the lines at once. Instead not using an iterator th…
klein648 Oct 26, 2024
87e7259
Made instance variables private as they are only used in the parsing …
klein648 Oct 26, 2024
fc33d0b
Using an iterator to read the lines from the file one by one instead …
klein648 Oct 26, 2024
3c8e1f3
Replaced source directory with the one from the file Locator
klein648 Oct 26, 2024
7e78943
Fixed typo in comment
klein648 Oct 26, 2024
3ff2e29
replaced addOne with +=
klein648 Oct 26, 2024
bb52cdf
Refactored Iterateconfigs to iterateConfigs
klein648 Oct 26, 2024
531468b
Refactored local variable names
klein648 Oct 26, 2024
c4a3984
Refactored addition and fixed a bug involving necessary parenthesis
klein648 Oct 26, 2024
7dcbbea
removed unneccesary collapse call
klein648 Oct 26, 2024
90be780
replaced for loop with forall()
klein648 Oct 26, 2024
8006f9a
refactored local variables
klein648 Oct 26, 2024
9aed96a
Replaced for loops with foreach
klein648 Oct 26, 2024
7e713d4
Removed Scala Version from search from target folder
klein648 Oct 26, 2024
3487ca8
Removed ambiguous comment
klein648 Oct 26, 2024
a3e4d94
Refactored SearchFiles() -> searchFiles()
klein648 Oct 26, 2024
d36435b
Start checking for empty comment first
klein648 Oct 26, 2024
e9e7270
Made the brief description length a configurable value
klein648 Oct 27, 2024
10a24a7
documented replaceClasses
klein648 Oct 27, 2024
01a6ed9
Fixed scaladoc comments
klein648 Oct 27, 2024
3ffbee6
Removed typesafe config from the dependencies
klein648 Oct 27, 2024
79ea534
Rebuilt Comment export to use a string builder
klein648 Nov 1, 2024
52894ee
Initializing the iterator as empty
klein648 Nov 1, 2024
ea80bd2
Importing configFactory
klein648 Nov 1, 2024
85779e3
Refactored Comment class to DocumentationComment class
klein648 Nov 1, 2024
44e279d
Implemented OPALLogger for output
klein648 Nov 1, 2024
7bdf267
Removed unnecessary trims
klein648 Nov 1, 2024
f90b791
Fixed comments
klein648 Nov 1, 2024
f24afbb
Removed trim
klein648 Nov 1, 2024
36ae3d1
Renamed Source Object to ConfigurationExplorer
klein648 Nov 1, 2024
644c7af
Removed iterator on string for finding terminating symbol
klein648 Nov 1, 2024
04f2da9
Separated parsing a single line of comment into a separate method.
klein648 Nov 1, 2024
c612982
Using index variable to save duplicate string searches
klein648 Nov 1, 2024
574482d
Rebuilt toHTML methods to both use a StringBuilder and String interpo…
klein648 Nov 1, 2024
a36b5f2
removed extractValue method and implemented String builder for multi-…
klein648 Nov 1, 2024
7397d3a
Renamed internal method to avoid ambiguities
klein648 Nov 1, 2024
aac8d6b
Replaced zip with index with indexWhere
klein648 Nov 1, 2024
bb25571
Made multiple return values immutable
klein648 Nov 1, 2024
cb419ff
Fixed typo
klein648 Nov 1, 2024
33a373d
Simplified isEmpty method
klein648 Nov 1, 2024
758b26c
specified exception type
klein648 Nov 1, 2024
3cbdf7d
Made Comment Parser an inner class of CommentParserWrapper
klein648 Nov 1, 2024
430c4fb
removed mutability of Config
klein648 Nov 1, 2024
d80abcc
removed currentComment var
klein648 Nov 1, 2024
9eeb20e
removed FirstIndexOfChars
klein648 Nov 1, 2024
0ce173a
Changed immutable.Seq to Seq
klein648 Nov 1, 2024
fee3be0
Refactored findJarArchives
klein648 Nov 1, 2024
b5ea6ff
Updated FileLocator comments
klein648 Nov 1, 2024
1252c98
Implemented proper escaping of special characters
klein648 Nov 1, 2024
a73a311
Style change
klein648 Nov 1, 2024
0b73533
Changed head definition
klein648 Nov 1, 2024
319d2ed
Reworked iterateConfigs method
klein648 Nov 3, 2024
a4527e6
Removed duplicate .depends on
klein648 Nov 3, 2024
e377228
Updated projectDependencies
klein648 Nov 3, 2024
23bdef6
Made values of DocumentationComment immutable and fixed everything th…
klein648 Nov 3, 2024
276fa09
Reformatted with scalafmt
klein648 Nov 3, 2024
6148d49
Reworked export process to only use one string builder
klein648 Nov 3, 2024
a816811
Removed unneccessary toSeq()
klein648 Nov 3, 2024
b1275b2
Refactored CommentParserWrapper into CommentParser
klein648 Nov 3, 2024
8d20035
Fixed comments
klein648 Nov 3, 2024
ab28661
Updated ProjectDependencies.svg
klein648 Nov 5, 2024
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
10 changes: 9 additions & 1 deletion OPAL/ProjectDependencies.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ flowchart BT
bp[BugPicker\n bp]
hermes[Hermes\n hermes]

ce[ConfigurationExplorer \n ce]

style common fill:#9cbecc,color:black
style framework fill:#c0ffc0
style bp fill:#ffd7cf
Expand Down Expand Up @@ -68,4 +70,10 @@ flowchart BT

demos --> framework
bp --> framework
hermes --> framework
hermes --> framework

ce --> br
ce --> apk
ce --> demos
ce --> hermes
ce --> bp
Binary file modified OPAL/ProjectDependencies.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion OPAL/ProjectDependencies.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions TOOLS/ce/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// build settings reside in the opal root build.sbt file
131 changes: 131 additions & 0 deletions TOOLS/ce/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Configuration explorer documentation
## How to document your configs
The configuration explorer uses a custom parser to parse flags into a browsable documentation
This makes every element of your config documentable.
This guide is about to teach you how to utilize these flags to create a comprehensible documentation

### How do I create a browsable configuration?
1. Start up your sbt shell
2. run the doc command
3. Open the generated commentedconfigs.html in your source directory

### Where can I add my documentation?
You can add your documentation in the lines before an element, or directly behind the element within the same line.

```
// You can either add your comment to the element here
Value = "one" //Or you can also add your comment here

// However, you cannot add your comment here
```

Also keep in mind that HOCON allows for multiple values within one line.
In this case, the comment will be associated with its closest neighbor that fullfills the criteria:

```
Object = {Key = "Value", AnotherKey = "SecondValue"} // This comment will be associated with Object, since its closing bracket is closest
```

Sub-values need to be placed in its own lines in order to be documented.

### Usage of flags

The configuration explorer allows for different flags to be utilized for different elements of the documentation.
Each flag will be interpreted differently and be represented in a different way after exporting.

The flags can be grouped in two groups, by the point in time where they are visible when the documentation is exported.

#### @label
@label documents the label of the object.
It will be shown in the documentation as the name of the object and will be visible even when the object is collapsed.
If the configuration element is part of an object, the label will be automatically set as its identifier within the object.
This is overridable by manually setting the @label flag within its documentation.

```
{
key = "value" // The label property will be set to "key" automatically.

//@label Custom label
another_key = "value" // The label property is now overridden to "Custom label"
}
```

#### @brief
@brief shows a brief description of the element for easier comprehension without the need for expanding the element.
For optimal formatting, try to keep the length of the text behind this flag below 50 characters.

#### @description
@description will set the description of the configuration element when the element is expanded.
Usage of the flag is optional, as unflagged content will be added to the description area too.

```
{
// @description You can use this flag to add this text to the elements description.
// However, without any flags, the text will be added to the description too.
key = "value"
}
```

#### @type
@type can be used to indicate the type of a value that will be used.

##### Subclass type
The subclass type is one of two special types currently implemented into Configuration Explorer
When tagged with a subclass type, configuration explorer will search for all subclasses of a given root class.

##### Enum type
The enum type is the second of the special types in Configuration Explorer. Use it if you have a finite amount of allowed values that you all want to list in the constraints.

##### Other types
You can pick a type that you want to indicate, which logical restraints are, but they will be treated as-is and not be refined further.

#### @constraint
Use @constraint to define which values are allowed and which are not.
If there are multiple constraints, use a new line for each constraint using the flag "@constraint" at the beginnning of each line.

There are currently two types implemented where you use a special style to list constraints:
##### Subclass type
If your type is "subclass", then list exactly one constraint. The constraint must be the class where all allowed classes inherit from.
Configuration Explorer will fetch all valid Subclasses of the listed class and list these in the documentation. You may specify a different value in the value field when generating the documentation.

Example:
```
{
// @description Configuration Explorer will list all subclasses of ConfigNode as allowed values. (Which are ConfigObject, ConfigList, ConfigEntry)
// @type subclass
// @constraint ConfigNode
value = ConfigObject
}
```

##### Enum type
Create one line with the constraint flag for every allowed value that you want to list.

Example:

```
{
// @description Add one row for each allowed value
// @type enum
// @constraint two
// @constraint three
// @constraint five
// @constraint seven
primeNumberBelowTen = 3
}
```

#### Other types
The constraints for other types will be passed as-is and can be in a free text.

Example:

```
{
// @type int
// @constraint Values must be within 0 and 100
// @constraint Values must be even
key = 2
}
```

61 changes: 61 additions & 0 deletions TOOLS/ce/src/main/resources/ce.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// @brief Configuration for the config explorer
// @description Settings under this hierarchy control the configuration explorer options

{
org.opalj.ce {
// @brief Used filenames for configurations
// @description This setting contains a list of filenames that are in use for configuration files in this project
// reference.conf, application.conf are default filenames defined by the maker of typesafe configuration
// @type String
configurationFilenames = ["ce.conf","reference.conf","application.conf", "hermes.conf","CommandLineProject.conf","LibraryProject.conf","NoTransformations.conf"]

// @brief Toggle for replacing classes in the configuration documentation
// @description You can use this option to activate / deactivate the replacement of subclass type configuration entries
// When activated, ce will list all implemented subclasses able to replace a class type value
// @type Boolean
replaceSubclasses = true

// @label HTML Settings
// @brief These settings store the information for the HTML export
html = {
// @brief Path to the HTMLTemplate
// @description This setting contains a relative path from the projects root to the file that stores the HTML Stylesheet and the JavaScript components
// @type String
// @constraint must be a path to an existing html file in Linux syntax (use / instead of \)
template = "/TOOLS/ce/src/main/resources/template.html"

// @brief Defines the headline of a config Node
// @description This sets the syntax for the headline of a config node.
// $label will be replaced with the label of the ConfigNode
// $brief will be replaced with the brief description of the ConfigNode
// This does not render correctly on the documentation due to it being an HTML expression
// @type String
// @constraint Must be a valid closed HTML expression
headline = "<h3 class=\"header\"> $label <span class=\"preview\">- $brief </span><span class=\"expandBox\">Show</span></h3>"

// @brief defines syntax of the content bracket
// @description This setting sets the syntax of the content brackets
// $content is a placeholder that will be replaced with the further content of the config node
// This does not render correctly on the documentation due to it being an HTML expression
// @type String
// @constraint Must be a valid closed HTML expression
// @constraint Must contain the placeholder $content
content = "<div class=\"content\"> $content </div>"

// @brief Defines the export path of the commented commentedconfigs
// @type String
// @constraint must be a file name
export = "/commentedconfigs.html"

// @brief Defines if the keys in the export should be sorted alphabetically
// @type boolean
sort_alphabetically = false

// @brief Defines how long the fallback preview of the brief description can be
// @description This value defines, how long the preview in the brief window can be, if there is not explicit brief description available.
// The number is the amount of characters displayed.
// @type Integer
maximum_headline_preview_length = 70
}
}
}
71 changes: 71 additions & 0 deletions TOOLS/ce/src/main/resources/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OPAL Config Documentation</title>
<style>
body {
font-family: sans-serif;
padding: 1em;
}

hr {
margin-top : 2em;
margin-bottom: 2em;
color: #DCDCDE;
}
.content {
padding: 1em;
border: 0.1em solid #DCDCDE;
border-radius: 0.5em;
margin-left: 2em;
display: none;
}

.header {
cursor: pointer;
color: #28272D;
background-color: #FBFAFD;
}

.preview {
font-weight: normal;
font-size: 0.65em;
color: #626168;
}

.expandBox {
float: right;
color: #626168;
font-size: 0.5em;
padding: 0.4em;
border: 0.1em solid #DCDCDE;
border-radius: 0.25em;
border-collapse: collapse;
}
</style>
</head>
<body>

$body

<script>
document.querySelectorAll('.header').forEach(header => {
header.addEventListener('click', () => {
const content = header.nextElementSibling;
const expandBox = header.querySelector('.expandBox');

if (content.style.display === 'none' || content.style.display === '') {
content.style.display = 'block';
expandBox.textContent = 'Hide';
} else {
content.style.display = 'none';
expandBox.textContent = 'Show';
}
});
});
</script>

</body>
</html>
Loading