Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS selectors #355

Merged
merged 19 commits into from Jul 3, 2020
Merged

CSS selectors #355

merged 19 commits into from Jul 3, 2020

Conversation

amolenaar
Copy link
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes

What is the current behavior?

A very limited level of styling is possible. Basically only one (wildcard) rule can be created, which is applicable for all diagram items.

Issue Number: #284

What is the new behavior?

image

CSS can be applied on:

  • item name
  • item hierarchy (nesting) in the diagram

@danyeaw danyeaw added the feature A new feature label Jun 30, 2020
@danyeaw danyeaw added this to the 2.0 milestone Jun 30, 2020
from gaphor.core.styling.declarations import StyleDeclarations, parse_declarations
from gaphor.core.styling.selectors import SelectorError, compile_selector_list

MATCH_SORT_KEY = operator.itemgetter(0, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, I wasn't familiar with using itemgetter as a sort key

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jul 3, 2020

Sourcery Code Quality Report (beta)

❌ Merging this PR will decrease code quality in the affected files by 0.03 out of 10.

Before After Change
Quality 9.02 9.0 -0.03
Complexity 1.34 1.39 0.06
Method Length 36.84 37.39 0.55
Lines 1217 1758 541
Changed files Quality Before Quality After Quality Change
gaphor/UML/classes/association.py 8.71 8.71 -0.0 ⬇️
gaphor/core/modeling/presentation.py 9.5 9.51 0.01 ⬆️
gaphor/core/styling/init.py N/A 8.6 N/A
gaphor/core/styling/parser.py N/A 9.0 N/A
gaphor/core/styling/selectors.py N/A 8.83 N/A
gaphor/core/styling/tests/test_selector.py N/A 9.07 N/A
gaphor/diagram/presentation.py 8.92 8.91 -0.01 ⬇️
gaphor/diagram/general/simpleitem.py 9.12 9.12 0.0 ⬆️
gaphor/diagram/tests/test_style.py 9.16 9.16 0.0

Here are some functions in these files that still need a tune-up:

File Function Quality Recommendation
gaphor/UML/classes/association.py AssociationEnd.post_update 3.72 Split out functionality
gaphor/core/styling/parser.py parse_attribute_selector 4.22 Split out functionality
gaphor/core/styling/parser.py parse_qualified_name 4.54 Split out functionality
gaphor/core/styling/parser.py parse_simple_selector 4.62 Split out functionality
gaphor/UML/classes/association.py AssociationItem.post_update 4.72 Split out functionality

Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it via email or our Gitter!

Copy link
Member

@danyeaw danyeaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice - really impressive you got this to work. 🎉 I didn't know anything about CSS selectors or specificity before reviewing this PR, but now I know just a little bit.

@danyeaw danyeaw merged commit cccea3b into master Jul 3, 2020
@danyeaw danyeaw deleted the css-selectors branch July 3, 2020 14:49
@amolenaar
Copy link
Member Author

With two bits of help from the cssselect2 code 😃 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants