{"id":16545547,"url":"https://github.com/BrainStormYourWayIn/sierra","last_synced_at":"2025-10-28T15:31:37.107Z","repository":{"id":48654076,"uuid":"374923209","full_name":"BrainStormYourWayIn/sierra","owner":"BrainStormYourWayIn","description":"A Python implementation of DOM","archived":false,"fork":false,"pushed_at":"2024-02-14T04:10:22.000Z","size":671,"stargazers_count":90,"open_issues_count":0,"forks_count":4,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-09-18T00:47:48.008Z","etag":null,"topics":["css","html","html-css","python","python-to-css","python-to-html","web-application"],"latest_commit_sha":null,"homepage":"https://brainstormyourwayin.github.io/sierra-documentation/Documentation.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BrainStormYourWayIn.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-06-08T07:36:39.000Z","updated_at":"2024-06-07T12:51:34.000Z","dependencies_parsed_at":"2024-01-03T05:33:05.658Z","dependency_job_id":"ad436614-fbcd-4bbd-b94f-875c18e9bd18","html_url":"https://github.com/BrainStormYourWayIn/sierra","commit_stats":{"total_commits":691,"total_committers":5,"mean_commits":138.2,"dds":"0.44428364688856725","last_synced_commit":"8cc04ca16fd1692d3c6af08f7a8470cc7c7d5acb"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrainStormYourWayIn%2Fsierra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrainStormYourWayIn%2Fsierra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrainStormYourWayIn%2Fsierra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrainStormYourWayIn%2Fsierra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BrainStormYourWayIn","download_url":"https://codeload.github.com/BrainStormYourWayIn/sierra/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219859192,"owners_count":16556036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","html","html-css","python","python-to-css","python-to-html","web-application"],"created_at":"2024-10-11T19:07:04.345Z","updated_at":"2025-10-28T15:31:37.099Z","avatar_url":"https://github.com/BrainStormYourWayIn.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["General HTML Generation"],"readme":"# sierra\n\n\u003cimg src=\"./assets/cover.jpg\" alt=\"Sierra\" style=\"width:100%;\"/\u003e\n\n![GitHub](https://img.shields.io/github/license/BrainStormYourWayIn/sierra?color=blue)\n[![Downloads](https://pepy.tech/badge/sierra)](https://pepy.tech/project/sierra)\n\nSierra is a Python library to write HTML/CSS/JS in pure Python in a simple yet elegant manner. \n\nHere are a few advantages of using Sierra over other Python libraries that use the DOM API:\n\n- Out-of-the-box support for all CSS styling attributes for all tags\n- Display a table by simply putting in a CSV file\n- Create your own tag functions with absolute ease using `@tag` and `@CmTag`. You can decide their behavior and use them within content-managers too\n- Improvement in the arrangement look of the code and intelligent handling of tags with    \n`autoPrettify()`\n\n\u003ca href=\"https://colab.research.google.com/github/pranavr2003/hvejbvfn/blob/main/sierra_interactive.ipynb\" target=\"_parent\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"autoPrettify()\"/\u003e\u003c/a\u003e\n\n________________________________\n\n## Documentation\n\n- **Check out the [documentation of Sierra](https://brainstormyourwayin.github.io/sierra-documentation/Documentation.html)**\n\n________________________________\n\n### Installation\n\n    pip install sierra\n\n### Upgrade\n\n    pip install --upgrade sierra\n    \n________________________________\n\nStarting off is pretty simple and straightforward:\n\n```python\nfrom sierra import *\n    \ntitle('Hello World!')\n```\n    \nThe `title()` function at the start is mandatory, since it commences the HTML and the CSS file, which is created in the working directory upon execution.\n\nYou can create custom tag functions with @tag and @CmTag. Say you want to create a function for \u0026lt;meta\u0026gt;:\n\n```python\n@tag\ndef meta(**kwargs):\n    pass\n        \n# Using them\n    \nmeta(name=\"description\", content=\"This is some description\")\nmeta(name=\"viewport\", content=\"width=device-width\", initial_scale=1.0)\n```\n\nUnderscores are used for hyphens (same applies to CSS) and Python-conficting arguments are prefixed with a double underscore Take `async`, for instance. This is demonstared below. Also is shown the implementation of the argument `text` inside of a function defined in `@tag`, which will create a tag that opens, enters text, and closes.  See how using `text` and `async` within `\u003cscript\u003e` works:\n\n```python\n@tag\ndef script(**kwargs):\n    pass\nscript(__async=\"\", src=\"some_src\", text=\"some_text\")\n```\nIs the equivalent of:\n```html\n\u003cscript async=\"\" src=\"some_src\"\u003esome_text\u003c/script\u003e\n```\nTo add JS, create a function for the \u0026lt;script\u0026gt; tag with a context manager behavior using `@CmTag`.   \n\n```python\n@CmTag\ndef script(**kwargs):\n    pass\n\n# Here I'll be replicating the script needed to add Google Analytics to a webpage\n\nwith script(__aync=\"\", src=\"https://www.googletagmanager.com/gtag/js?id=UA—XXXXXXXX-X\"):\n    pass\n    \nwith script():\n\n    writeWA('''\n  window.dataLayer = window.dataLayer || [];\n  function gtag(){dataLayer.push(arguments);}\n  gtag('js', new Date());\n  gtag('config', 'UA—XXXXXXXX-X');\n  ''')\n```\nThis is the equivalent of:\n```html\n\u003cscript async src=\"https://www.googletagmanager.com/gtag/js?id=UA—XXXXXXXX-X\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\n    \n  window.dataLayer = window.dataLayer || [];\n  function gtag(){dataLayer.push(arguments);}\n  gtag('js', new Date());\n  gtag('config', 'UA—XXXXXXXX-X');\n    \n\u003c/script\u003e\n```\n`writeWA()` writes text entered into it into the HTML file as it is. \n\nYou can add fonts using `addFont()`\n```python\naddFont(\"https://fonts.googleapis.com/css2?family=Roboto\u0026display=swap\")\n```\nOnce things at the `\u003chead\u003e` of the HTML are settled (CSS is automatically linked), begin the body of the HTML with\n```python\nopenBody()\n# You can add any number of styling arguments to the body within openBody()\nopenBody(background_color='yellowgreen', opacity='0.9')\n```\nYou can create `div` and `section` tags this way:\n```python\nwith div(__class=\"some_class\") as d:\n    p('This is a paragraph!')\n    d.css(background_color=\"#5886d1\")\n```\nLet's break this down bit-by-bit:  \nFirst, we start a `div` with a context manager behavior and give it an attribute `__class`, which is essentially the tag attribute `class` (remember Python-conflicting arguments are prefixed by a double underscore).\n\n`p()` is a function, as the name suggests, to add a `\u003cp\u003e` tag. You can give the tag attributes with `**kwargs`, if you like.   \n`p('Hello World!', __class='p_class')` is the same as `\u003cp class=\"p_class\"\u003eHello World!\u003c/p\u003e`\n\nAfter the paragraph, there's a `d.css()`. This adds CSS to the `class` mentioned within `div()`. If a `class` is mentioned, CSS is added to that class as the first priority. If an `id` is mentioned, CSS is added to that `id` as a second priority. If none of both are mentioned, CSS is just added to `div`.\n\nThe behavior of `div` shown above also applies to `section`.\n\nYou can open a new tag with `Tag()`\n```python\nwith Tag('some_tag', id='some_id') as t:\n    p('A paragraph in \u003csome_tag\u003e')\n    t.css(color='blue')\n```\nAlthough here, `.css()` behaves differently. It is independent of tag attributes, meaning CSS is added directly to the tag mentioned, which is `some_tag`\n\nTo add CSS to a specific attribute in the tag, use `writeCSS()`\n```python\nwriteCSS(tag_name, **kwargs)\n\nwriteCSS(\"#some_id\", color='blue')\n```\nThis adds CSS to the `some_id`.\n\nYou can add a table to the HTML page by inputting in a CSV file this way:\n```python\nwith Table() as t:\n    t.get_table(\"path/to/file.csv\")   # Add attributes with **kwargs here\n    t.css(border=\"1px solid black\")   # Use writeCSS to add CSS to a specific attribute\n```\nHere are all of Sierra's functionalities - [documentation](https://brainstormyourwayin.github.io/sierra-documentation/Documentation.html)\n\nAt the end of all development with Sierra, use\n```python\nautoPrettify()\n```\nIt takes in no arguments, but closes unclosed togs and aligns the code in the output files.\n\nThe working of `autoPrettify()`:\n   \n\u003cp align=center\u003e\n\u003ca href=\"https://colab.research.google.com/github/pranavr2003/hvejbvfn/blob/main/sierra_interactive.ipynb\" target=\"_parent\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n________________________________\n\n### Contact Us\n\nEmail: brainstormyourwayin@gmail.com\n\n**Or you can contact either of us individually if you like. See our individual GitHub profiles for information**.\n\n________________________________\n\n**Open with GitPod**\n\n[![GitPod](https://www.gitpod.io/svg/media-kit/logo-dark-theme.svg)](https://gitpod.io/#https://github.com/BrainStormYourWayIn/sierra/)\n\n________________________________\n\n## License\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n\u003e Pandas (pandas)\n\u003e\n\u003e\u003e Copyright (c) 2008-2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team.    \n\u003e\u003e Copyright (c) 2011-2020, Open source contributors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBrainStormYourWayIn%2Fsierra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBrainStormYourWayIn%2Fsierra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBrainStormYourWayIn%2Fsierra/lists"}