Flaxon 0.3.0 and Teloce-Py 0.3.0 are available on PyPI. Release instructions are maintained on this site; source links identify the framework snapshot. Check version and upgrade guidance.
Flaxon VS Code Extension - Advanced Guide
Overview
This guide covers advanced usage, customization, performance tuning, debugging, and troubleshooting for the Flaxon VS Code Extension.
๐งฉ Extending the Extension
Custom Snippets
You can create your own snippets by editing:
snippets/flaxon.json
Example
{
"Custom Route": {
"prefix": ["croute"],
"body": [
"@app.${1:get}(\"${2:/api/${3:resource}}\")",
"async def ${4:handler}(request):",
" \"\"\"${5:Custom handler}.\"\"\"",
" return {\"message\": \"${6:Custom response}\"}"
],
"description": "Custom route template"
}
}
Custom Commands
Add custom commands to your extension's package.json.
Example
{
"contributes": {
"commands": [
{
"command": "flaxon.customCommand",
"title": "Flaxon: Custom Command",
"category": "Flaxon"
}
]
}
}
๐ง Language Server
How It Works
The Flaxon Language Server (LSP) runs as a background Python process and provides intelligent editor features.
It performs the following tasks:
- Parses Python source files
- Builds an Abstract Syntax Tree (AST)
- Detects routes, schemas, and imports
- Provides auto-completion
- Generates diagnostics
- Displays hover documentation
Language Server Lifecycle
1. Extension activates
โ
โผ
2. Language Server starts
โ
โผ
3. Python file is opened
โ
โผ
4. Routes and symbols are indexed
โ
โผ
5. Completions and diagnostics become available
โ
โผ
6. File changes trigger automatic updates
โ
โผ
7. VS Code closes โ Language Server exits
Restarting the Language Server
Open the Command Palette and run:
Flaxon: Restart Language Server
Viewing Server Logs
- Open the Output panel (
Ctrl+Shift+U). - Select Flaxon from the dropdown.
- Enable verbose logging:
{
"flaxon.trace.server": "verbose"
}
๐ฏ Customizing the Route Explorer
Route Grouping
Routes can be grouped in different ways.
{
"flaxon.routeExplorer": {
"groupBy": "file",
"showMethods": true,
"showLineNumbers": true
}
}
Available Grouping Options
| Option | Description |
|---|---|
file |
Group routes by source file. |
prefix |
Group routes by URL prefix. |
tag |
Group routes by route tag. |
Adding Route Metadata
Named routes improve organization and navigation.
@app.get("/api/users", name="user.list")
async def get_users():
return {"users": []}
@app.get("/api/users/<int:id>", name="user.detail")
async def get_user(id: int):
return {"id": id}
๐ Advanced Debugging
Attach to a Running Process
Start your Flaxon application, then attach the debugger.
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
}
}
Debug with Environment Variables
{
"name": "Flaxon: Debug with Environment",
"type": "python",
"request": "launch",
"module": "flaxon",
"args": [
"run",
"app:app"
],
"env": {
"FLASK_ENV": "development",
"DATABASE_URL": "postgresql://localhost/mydb"
}
}
Debug with Command-Line Arguments
{
"name": "Flaxon: Debug with Arguments",
"type": "python",
"request": "launch",
"module": "flaxon",
"args": [
"run",
"app:app",
"--host",
"0.0.0.0",
"--port",
"5000"
]
}
๐ Performance Optimization
Large Projects
For larger projects, the following settings are recommended.
| Setting | Recommended Value |
|---|---|
flaxon.enableRouteExplorer |
true |
flaxon.enableCodeLens |
true |
flaxon.enableDiagnostics |
true |
flaxon.enableCompletions |
true |
flaxon.trace.server |
"off" |
Increase Language Server Memory
{
"flaxon.languageServer": {
"memoryLimit": 1024
}
}
Exclude Large Directories
{
"files.watcherExclude": {
"**/.venv/**": true,
"**/node_modules/**": true,
"**/__pycache__/**": true
}
}
๐ Integration with Other Extensions
Python Extension
The Flaxon extension works best alongside:
| Extension | Purpose |
|---|---|
ms-python.python |
Python language support |
ms-python.vscode-pylance |
Type checking and IntelliSense |
Git Integration
Flaxon integrates with Git by:
- Refreshing the Route Explorer after changes
- Tracking modified route files
- Working seamlessly with Git diff views
Testing Extensions
| Extension | Purpose |
|---|---|
vscode.pytest |
Run Python tests |
hbenl.vscode-test-explorer |
View test results |
๐ก๏ธ Security
Trusted Workspaces
The extension only activates in trusted workspaces.
{
"security.workspace.trust.enabled": true
}
Privacy
The extension does not:
- Send your source code to external servers
- Track personal usage
- Store credentials
Environment Variables
Configure environment variables for the integrated terminal.
{
"terminal.integrated.env.windows": {
"FLAXON_ENV": "production"
}
}
๐ CI/CD Integration
CLI Commands
The extension uses the Flaxon CLI internally.
# Validate project
flaxon doctor app:app
# List routes
flaxon routes app:app
# Run tests
pytest
GitHub Actions
- name: Check Flaxon Project
run: |
pip install flaxon
flaxon doctor app:app
flaxon routes app:app
๐ Daily Workflow
Typical Development Workflow
- Open your project.
- Route Explorer loads automatically.
- Create a new route using snippets.
- View discovered routes.
- Run or debug your application.
- Test your code.
- Commit your changes.
Advanced Workflow
- Multiple workspace folders
- Shared snippets
- Shared workspace settings
- Route Explorer during code reviews
- Automatic API documentation support
๐ฏ Productivity Tips
| Tip | Description |
|---|---|
Ctrl+Shift+R |
Quickly open Route Explorer |
Ctrl+Shift+F5 |
Run the application |
| Snippets | Use froute, fschema, and fws |
| CodeLens | Run and debug directly from routes |
| Route Explorer | Click routes to navigate instantly |
Advanced Tips
| Tip | Description |
|---|---|
| Custom Snippets | Create project-specific templates |
| Workspace Settings | Customize behavior per project |
| Multi-root Workspaces | Work with multiple Flaxon projects |
| Remote Development | Compatible with VS Code Remote |
๐ Common Issues
Language Server Crashes
Symptoms
- Auto-completion stops working
- Diagnostics disappear
- Hover documentation is unavailable
Solutions
- Restart the Language Server.
- Verify Python and Flaxon are installed.
- Increase the Language Server memory limit.
Route Explorer Not Updating
Symptoms
Routes do not appear or refresh.
Solutions
- Save the file.
- Refresh the Route Explorer.
- Restart VS Code.
CodeLens Missing
Symptoms
Run and Debug buttons are not visible.
Solutions
- Enable
flaxon.enableCodeLens. - Save the file.
- Restart the Language Server.
Auto-Completion Missing
Symptoms
No suggestions appear while typing.
Solutions
- Enable
flaxon.enableCompletions. - Ensure the Python Language Server is running.
- Restart VS Code.
๐ Telemetry
Data Collection
| Data | Collected |
|---|---|
| Commands Used | โ |
| Errors | โ |
| Performance Metrics | โ |
| Source Code | โ |
| File Contents | โ |
Disable Telemetry
{
"flaxon.telemetry.enabled": false
}
๐ Version History
Version 0.1.2
Initial release including:
- Route Explorer
- CodeLens
- Auto-completion
- Hover Documentation
- Diagnostics
- Code Snippets
- Commands
- Language Server
Planned Features
| Feature | Target Version |
|---|---|
| GraphQL Schema Explorer | 0.2.0 |
| Admin Dashboard Preview | 0.3.0 |
| Plugin Development Tools | 0.4.0 |
| Performance Profiling | 0.5.0 |
๐ Resources
Official Resources
- ๐ Documentation
- ๐ Website
- ๐ GitHub
- ๐ฆ Visual Studio Marketplace
Community
- ๐ฌ Discussions
- ๐ Issue Tracker
The Flaxon VS Code Extension is designed to make Flaxon development faster, smarter, and more enjoyable. Happy coding! ๐