Skip to content

Mattwmaster58/playwright-python-language-injection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

playwright-python-language-injection

Demo

Before

picture of IDE before

After

picture of IDE after

What is this?

This repo contains the script to generate language injection definitions for using playwright-python in PyCharm. From the link:

Language injections let you work with pieces of code in other languages embedded in your code. When you inject a language (such as HTML, CSS, XML, RegExp, and so on) into a string literal, you get comprehensive code assistance for editing that literal.

How do I use this?

The script generate.py generates a file playwright-X.xml where X is the major component of the installed playwright version. Or, you can just download the last generated version directly.

After downloading, open up your settings in PyCharm → Editor → Language Injections → Import, and select the file you just downloaded.

screenshot of settings page

How does this work?

Since the developers of playwright-python were consistent with their style, that made this script a lot easier to write. Every single occurrence of a CSS selector argument in a function uses the name selector and every occurrence of a JS expression uses the argument name expression. So it's as simple as iterating over the entire API surface, and finding methods that have arguments that match the name and type annotation of str. Both async and sync APIs are supported.

About

language injection definitions for PyCharm with playwright-python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages