Skip to content

Commit b4370d8

Browse files
committed
readme, packageing changes
1 parent 3054910 commit b4370d8

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ dist/*
1010
!dist/virtualfs.js.map
1111
!dist/phoenix-fs.js
1212
test/dist/
13+
phcode-language-support-1.0.0.tgz

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,54 @@ Inorder to publish the package to npm, do the following
7575
1. run `npm run relese` and push changes to main branch.
7676
2. raise a pull request from `main` branch to `npm` branch. Once the pull request is merged
7777
and the code pushed to npm branch, GitHub actions will automatically publish the library to npm.
78+
79+
## API
80+
81+
Below is a markdown documentation for the `CSSLanguageService` object, detailing its functions and usage. This can be used as part of a project's documentation, README, or developer guide.
82+
83+
---
84+
85+
## CSSLanguageService API
86+
87+
The `CSSLanguageService` provides utility functions for parsing CSS and
88+
retrieving CSS selectors(document symbols such as classes, IDs, and other selectors) from given text content.
89+
90+
### Methods
91+
92+
#### `getAllSymbols(text, cssMode, filePath)`
93+
94+
Retrieves all CSS selectors from the provided CSS text as an array of strings.
95+
96+
**Parameters**:
97+
98+
- `text` (`string`): The CSS code to analyze.
99+
- `cssMode` (`string`): The mode of the CSS document. This should correspond to one of the supported CSS modes (e.g., CSS, SCSS, LESS) defined in `CSS_MODES`.
100+
- `filePath` (`string`): Optional. The path of the CSS file, used for resolving relative URLs within the CSS. Defaults to `"file://placeholder.css"`.
101+
102+
**Returns**:
103+
104+
- `Array[string]`: An array containing all the CSS selectors found in the document.
105+
106+
**Example Usage**:
107+
108+
```javascript
109+
const cssText = ".class { color: red; } #id { margin: 10px; }";
110+
const selectors = CSSLanguageService.getAllSymbols(cssText, CSSLanguageService.CSS_MODES.CSS);
111+
console.log(selectors); // Output: [".class", "#id"]
112+
```
113+
114+
### Constants
115+
116+
#### `CSSLanguageService.CSS_MODES`
117+
118+
Defines the supported CSS modes for the `getAllSymbols` function. Includes:
119+
120+
- `CSS`: Standard CSS.
121+
- `SCSS`: Sassy CSS (SCSS).
122+
- `LESS`: Leaner Style Sheets (LESS).
123+
124+
**Example**:
125+
126+
```javascript
127+
console.log(CSSLanguageService.CSS_MODES.CSS); // Output: "CSS"
128+
```

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"url": "https://github.com/phcode-dev/language-support"
3131
},
3232
"files": [
33-
"dist/virtualfs.js"
33+
"dist/language-worker.js",
34+
"dist/language-worker-debug.js"
3435
],
3536
"devDependencies": {
3637
"vscode-css-languageservice": "^6.0.0",

0 commit comments

Comments
 (0)