1
- import * as fs from 'fs' ;
2
1
import * as vscode from 'vscode' ;
3
2
4
3
export const FORTRAN_KEYWORDS = [
@@ -15,45 +14,6 @@ export const FORTRAN_KEYWORDS = [
15
14
'IMPLICIT' ,
16
15
] ;
17
16
18
- export const _loadDocString = ( keyword : string ) => {
19
- keyword = keyword . toUpperCase ( ) ;
20
-
21
- const docStringBuffer = fs . readFileSync ( __dirname + '/../../../src/docs/' + keyword + '.html' ) ;
22
- let docText = docStringBuffer . toString ( ) ;
23
- const codeRegex = / < c o d e > ( .+ ?) < \/ c o d e > \n ? / g;
24
- const varRegex = / < v a r > ( .+ ?) < \/ v a r > / g;
25
- const spanRegex = / < s a m p > < s p a n c l a s s = " c o m m a n d " > ( \w + ) < \/ s p a n > < \/ s a m p > / g;
26
- const tableRegex = / < t a b l e \s * .* > ( [ \s \w < > / \W ] + ?) < \/ t a b l e > / g;
27
- const codeExampleRegex = / < c o d e c l a s s = " s m a l l e x a m p l e " [ \s \W \w ] * ?> ( [ \s \W \w < > ] * ?) < \/ c o d e > / g;
28
- const headerRegex = / ^ * < h ( \d ) > ( .+ ?) < \/ h \1> \n ? / gm;
29
- const defListRegex = / < d t > ( [ \w \W ] + ?) < \/ d t > < d d > ( [ \w \W ] + ?) ( < b r > ) ? < \/ d d > / g;
30
-
31
- docText = docText
32
- . replace ( varRegex , ( match , code : string ) => {
33
- return '`' + code + '`' ;
34
- } )
35
- . replace ( spanRegex , ( match , code ) => `*${ code } *` )
36
- . replace ( defListRegex , ( match , entry , def ) => `**${ entry } ** ${ def } \n` )
37
- . replace ( codeExampleRegex , ( match , code ) => '```\n' + code + '\n\n```\n' )
38
- . replace ( / < t d \s * .* ?> ( [ \s \w < > / \W ] + ?) < \/ t d > / g, ( match , code ) => ' | ' + code )
39
- . replace ( / < t r \s * .* ?> ( [ \s \w < > / \W ] + ?) < \/ t r > / g, ( match , code ) => code + '\n' )
40
- . replace ( / < t b o d y \s * .* ?> ( [ \s \w < > / \W ] + ?) < \/ t b o d y > / g, ( match , code ) => code )
41
- . replace ( tableRegex , ( match , code ) => code )
42
- . replace ( codeRegex , ( match , code : string ) => {
43
- return '`' + code + '`' ;
44
- } )
45
- . replace ( / < p > \s * ?/ g, '\n' )
46
- . replace ( / < \/ p > \s * ?/ g, '\n' )
47
- . replace ( headerRegex , ( match , h : string , code : string ) => {
48
- const headerLevel : number = parseInt ( h ) ;
49
- const header = '#' . repeat ( headerLevel ) ;
50
- return `${ header } ${ code } \n` ;
51
- } ) ;
52
- docText = docText . replace ( / ^ * < b r > \n ? / gm, '\n' ) . replace ( / < \? d l > / g, '' ) ;
53
- console . log ( docText ) ;
54
- return docText ;
55
- } ;
56
-
57
17
export function isPositionInString (
58
18
document : vscode . TextDocument ,
59
19
position : vscode . Position
@@ -69,15 +29,6 @@ export function isPositionInString(
69
29
return doubleQuotesCnt % 2 === 1 ;
70
30
}
71
31
72
- const saveKeywordToJson = keyword => {
73
- const doc = _loadDocString ( keyword ) ;
74
- const docObject = JSON . stringify ( { keyword : keyword , docstr : doc } ) ;
75
- fs . appendFile ( 'src/docs/' + keyword + '.json' , docObject , function ( err ) {
76
- if ( err ) throw err ;
77
- console . log ( 'Saved!' ) ;
78
- } ) ;
79
- } ;
80
-
81
32
export const delay = ( ms : number ) => new Promise ( res => setTimeout ( res , ms ) ) ;
82
33
83
34
export function isUri ( input : any ) : input is vscode . Uri {
0 commit comments