Giter Club home page Giter Club logo

cartocss-doc-parser's Introduction

cartocss-doc-parser

PyPI Python versions Tests Coverage Status

CartoCSS documentation Python parser.

Install

pip install cartocss-doc-parser

Quickstart

The main function cartocss_doc returns a dictionary with almost every section of the documentation. All the properties are wrapped in generators.

>>> from pprint import pprint
>>> from cartocss_doc_parser import cartocss_doc
>>>
>>> doc = cartocss_doc()
>>> pprint(doc)
{'building': <generator object ...>,
 'common_elements': <generator object ...>,
 'line': <generator object ...>,
 'line_pattern': <generator object ...>,
 'map_background_and_string_elements': <generator object ...>,
 'markers': <generator object ...>,
 'other_parameters': <generator object ...>,
 'point': <generator object ...>,
 'polygon': <generator object ...>,
 'polygon_pattern': <generator object ...>,
 'raster': <generator object ...>,
 'shield': <generator object ...>,
 'symbolizers': <generator object ...>,
 'text': <generator object ...>,
 'torque_properties': <generator object ...>,
 'values': <generator object ...>}

All properties contains the attributes

  • default Default value.
  • description Description.
  • id Identificator.
  • link Link to the property on documentation.
  • name Name of the property.
  • sample Example of use.
  • type Value data type. For a complete list see cartocss_data_types.

and if the data type is keyword contains an additional attribute

  • variants Possible values for the property.
>>> pprint(list(doc["polygon"]))
[{'default': 'gray',
  'description': 'The fill color assigned to a polygon.',
  'id': 'polygon-fill-color',
  'link': 'https://carto.com/developers/styling/cartocss/#polygon-fill-color',
  'name': 'polygon-fill',
  'sample': 'polygon-fill: rgba(128, 128, 128, 1);',
  'type': 'color'},
 {'default': '1',
  'description': 'The opacity of the polygon.',
  'id': 'polygon-opacity-float',
  'link': 'https://carto.com/developers/styling/cartocss/#polygon-opacity-float',
  'name': 'polygon-opacity',
  'sample': 'polygon-opacity: 1;',
  'type': 'float'},
 ...,
 {'default': 'power',
  'description': 'An anti-grain geometry method that represents a 2D rendering '
                 'library, specific to controlling the quality of antialiasing '
                 'and used to calculate pixel gamma (pow(x,gamma), which '
                 'produces slightly smoother line and polygon antialiasing '
                 "than the 'linear' method.",
  'id': 'polygon-gamma-method-keyword',
  'link': 'https://carto.com/developers/styling/cartocss/#polygon-gamma-method-keyword',
  'name': 'polygon-gamma-method',
  'sample': 'polygon-gamma-method: power;',
  'type': 'keyword',
  'variants': ['power', 'linear', 'none', 'threshold', 'multiply']},
 ...
]

All data types can be requested with cartocss_data_types function:

>>> from cartocss_doc_parser import cartocss_data_types
>>> pprint(list(cartocss_data_types()))
['color',
 'float',
 'uri',
 'string',
 'boolean',
 'expression',
 'numbers',
 'number',
 'percentages',
 'percentage',
 'functions',
 'function',
 'keyword',
 'unsigned',
 'tags']

Documentation

# cartocss_doc(url="https://carto.com/developers/styling/cartocss/", user_agent="cartocss_doc_parser vX.Y.Z") โ‡’ dict

Provides information for almost every section of CartoCSS documentation.

  • url (str) URL to the documentation page. Can be a local file, in which case any HTTP request would be performed, instead the file would be read.
  • user_agent (str) User agent performing the HTTP request to documentation page. As default is cartocss_doc_parser (v%(version)s).

# cartocss_data_types(url="https://carto.com/developers/styling/cartocss/", user_agent="cartocss_doc_parser vX.Y.Z") โ‡’ gen

Lists all available data types for properties for CartoCSS.

  • url (str) URL to the documentation page. Can be a local file, in which case any HTTP request would be performed, instead the file would be read.
  • user_agent (str) User agent performing the HTTP request to documentation page. As default is cartocss_doc_parser (v%(version)s).

cartocss-doc-parser's People

Contributors

mondeja avatar dependabot[bot] avatar github-actions[bot] avatar renovate[bot] avatar renovate-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.