@@ -11,6 +11,7 @@ import themeLight from '@/monaco/theme/editor.light.theme.json'
1111
1212import { MonacoLanguageImports } from '@/dynamicImports'
1313import type { KlippyApp } from '@/store/printer/types'
14+ import type { Globals } from '@/globals'
1415
1516type ReduceState < T > = {
1617 current ?: T ,
@@ -31,7 +32,12 @@ const isCodeLensSupportedService = (service: string): service is CodeLensSupport
3132 'crowsnest'
3233] . includes ( service )
3334
34- const getDocsSection = ( service : CodeLensSupportedService , sectionName : string ) => {
35+ type DocsSectionService = (
36+ CodeLensSupportedService |
37+ keyof typeof Globals . SUPPORTED_SERVICES . klipper
38+ )
39+
40+ const getDocsSectionHash = ( service : DocsSectionService , sectionName : string ) => {
3541 switch ( service ) {
3642 case 'klipper' :
3743 if ( sectionName . startsWith ( 'stepper_' ) ) {
@@ -44,6 +50,18 @@ const getDocsSection = (service: CodeLensSupportedService, sectionName: string)
4450
4551 break
4652
53+ case 'danger-klipper' :
54+ case 'kalico' :
55+ if ( sectionName === 'danger_options' ) {
56+ return 'danger-options'
57+ }
58+
59+ if ( sectionName === 'constants' ) {
60+ return 'configuration-references'
61+ }
62+
63+ return getDocsSectionHash ( 'klipper' , sectionName )
64+
4765 case 'moonraker' :
4866 if ( sectionName . startsWith ( 'include' ) ) {
4967 return 'include-directives'
@@ -97,10 +115,10 @@ async function setupMonaco () {
97115 } )
98116
99117 const app = getVueApp ( )
118+ const klippyApp = app . $store . getters [ 'printer/getKlippyApp' ] as KlippyApp
100119
101120 monaco . editor . registerCommand ( 'fluidd_open_docs' , ( _ , service : CodeLensSupportedService , hash : string ) => {
102121 const serviceKey = service . replace ( / - / g, '_' )
103- const klippyApp = app . $store . getters [ 'printer/getKlippyApp' ] as KlippyApp
104122
105123 const url = app . $t ( `app.file_system.url.${ serviceKey } _config` , {
106124 hash,
@@ -118,6 +136,10 @@ async function setupMonaco () {
118136 return null
119137 }
120138
139+ const docsSectionService : DocsSectionService = service === 'klipper'
140+ ? klippyApp . name
141+ : service
142+
121143 const linesContent = model . getLinesContent ( )
122144
123145 const sectionBlocks = linesContent
@@ -127,10 +149,11 @@ async function setupMonaco () {
127149 if ( section ) {
128150 const [ sectionName ] = section [ 1 ] . split ( ' ' , 1 )
129151
130- const referenceSection = getDocsSection ( service , sectionName )
152+ const hash = getDocsSectionHash ( docsSectionService , sectionName )
131153
132154 state . result . push ( state . current = {
133- referenceSection,
155+ sectionName,
156+ hash,
134157 range : {
135158 startLineNumber : index + 1 ,
136159 startColumn : model . getLineFirstNonWhitespaceColumn ( index + 1 ) ,
@@ -151,7 +174,7 @@ async function setupMonaco () {
151174 }
152175
153176 return state
154- } , { result : [ ] } as ReduceState < { referenceSection : string , range : monaco . IRange } > )
177+ } , { result : [ ] } as ReduceState < { sectionName : string , hash : string , range : monaco . IRange } > )
155178 . result
156179
157180 return {
@@ -161,8 +184,8 @@ async function setupMonaco () {
161184 id : `docs${ index } ` ,
162185 command : {
163186 id : 'fluidd_open_docs' ,
164- title : app . $t ( 'app.file_system.label.view_section_documentation' , { section : section . referenceSection } ) . toString ( ) ,
165- arguments : [ service , section . referenceSection ]
187+ title : app . $t ( 'app.file_system.label.view_section_documentation' , { section : section . sectionName } ) . toString ( ) ,
188+ arguments : [ service , section . hash ]
166189 }
167190 } ) ) ,
168191 dispose : ( ) => undefined
0 commit comments