Skip to content

Commit 7df3522

Browse files
committed
wip
1 parent 87b4d95 commit 7df3522

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs

+25-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import Data.List.Extra (nubOrd)
1616
import Data.String (IsString (fromString))
1717
import qualified Data.Text as T
1818
import Ide.Plugin.Config
19-
import Ide.Plugin.Properties (toDefaultJSON,
20-
toVSCodeExtensionSchema)
19+
import Ide.Plugin.Properties (Properties(..), toDefaultJSON,
20+
toVSCodeExtensionSchema, SPropertyKey (SProperties), MetaData (..), SomePropertyKeyWithMetaData (..))
2121
import Ide.Types
2222
import Language.LSP.Protocol.Message
23+
import GHC.TypeLits (symbolVal)
2324

2425
-- Attention:
2526
-- 'diagnosticsOn' will never be added into the default config or the schema,
@@ -139,3 +140,25 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug
139140
]
140141
withIdPrefix x = "haskell.plugin." <> pId <> "." <> x
141142
toKey' = fromString . T.unpack . withIdPrefix
143+
144+
-- | Generates markdown tables for custom config
145+
pluginsCustomConfigToMarkdownTables :: IdePlugins a -> T.Text
146+
pluginsCustomConfigToMarkdownTables IdePlugins {..} = T.unlines $ map singlePlugin ipMap
147+
where
148+
singlePlugin PluginDescriptor {pluginConfigDescriptor = ConfigDescriptor {configCustomConfig = c}, pluginId = PluginId pId} =
149+
T.unlines (pluginHeader : tableHeader : rows c)
150+
where
151+
pluginHeader = "## " <> pId
152+
tableHeader = "| Property | Description | Default |"
153+
rows (CustomConfig p) = toMarkdownTable p
154+
toMarkdownTable :: Properties r -> [T.Text]
155+
toMarkdownTable EmptyProperties = mempty
156+
toMarkdownTable (ConsProperties keyNameProxy k m xs) = renderRow (T.pack $ symbolVal keyNameProxy) (SomePropertyKeyWithMetaData k m) : toMarkdownTable xs
157+
renderRow :: T.Text -> SomePropertyKeyWithMetaData -> T.Text
158+
renderRow key (SomePropertyKeyWithMetaData k m) =
159+
let (desc, defaultVal) = case m of
160+
PropertiesMetaData _ desc _ -> (desc, False)
161+
EnumMetaData _ desc _ _ -> ("", True)
162+
MetaData _ desc -> (desc, False)
163+
in T.unwords ["|", key, "|", desc, "|", if defaultVal then "yes" else "no", "|"]
164+

hls-plugin-api/src/Ide/Plugin/Properties.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ module Ide.Plugin.Properties
2121
MetaData (..),
2222
PropertyKey (..),
2323
SPropertyKey (..),
24+
SomePropertyKeyWithMetaData (..),
2425
KeyNameProxy (..),
2526
KeyNamePath (..),
26-
Properties,
27+
Properties(..),
2728
HasProperty,
2829
HasPropertyByPath,
2930
emptyProperties,

src/Ide/Arguments.hs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ data Arguments
3333
| BiosMode BiosAction
3434
| Ghcide GhcideArguments
3535
| VSCodeExtensionSchemaMode
36+
| PluginsCustomConfigMarkdownReferenceMode
3637
| DefaultConfigurationMode
3738
| PrintLibDir
3839

0 commit comments

Comments
 (0)