1

I am trying to write a python script that will pull tickets from Jira via a JQL query, transpose them into an HTML format, and generate a release notes document to be POSTed to our knowledge base API.

I'm not very familiar with HTML table formats, so hopefully there's a library or something out there that can assist.

The JSON output will look like this: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-get

and the HTML output for an article with the correct formatting looks like this:

{
    "valid": true,
    "data": {
        "id": "",
        "type": "article",
        "category": "",
        "current_version_id": "",
        "modified_author": "",
        "category_view": false,
        "content_article": null,
        "article_link": null,
        "author": "",
        "summary": "          Test Release Notes  March 17, 2022        We are glad to inform you that the latest version [versionName] has been released. Below is the list of development tickets that were part of this upgrade.        Platform           T...",
        "project_id": "",
        "name": "Test Release Notes",
        "toc_title": "",
        "internal_title": "",
        "meta_description": "",
        "meta_page_title": "",
        "version_note": "",
        "url_hash": "test-release-notes",
        "pdf": "/home/pdfexport/id/",
        "searchTitle": {
            "en": "Test Release Notes"
        },
        "internal_note": null,
        "current_version": {
            "en": {
                "title": "Test Release Notes",
                "text": "<p><span style=\"font-family: arial, helvetica, sans-serif; font-size: 14px;\"><span style=\"font-size: 28px;\"><strong><img src=\"https://arn-resources.upraise.io/93c09ad4-8e4b-398f-9795-62f5ea84ea53/10049/49471/images/arn_file_2022-04-26-16-04-59-118.jpeg\" alt=\"\" width=\"420\" class=\"fr-fic fr-dii\" style=\"width: 54%;\"></strong></span></span></p><h2>Test Release Notes</h2><h3>March 17, 2022<br><span style=\"font-family: arial, helvetica, sans-serif; font-size: 14px;\">&nbsp;<img src=\"https://arn-resources.upraise.io/93c09ad4-8e4b-398f-9795-62f5ea84ea53/10069/47796/images/arn_file_2022-01-26-19-17-43-144.png\" alt=\"\" width=\"78\" height=\"12\" class=\"fr-fic fr-dii\"></span></h3><p><span style=\"font-size: 16px; font-family: arial, helvetica, sans-serif;\">We are glad to inform you that the latest version [versionName] has been released. Below is the list of development tickets that were part of this upgrade.</span></p><p>&nbsp;</p><p><span style=\"font-size: 26px; font-family: arial, helvetica, sans-serif;\"><strong>Platform</strong></span>&nbsp;</p><p><br></p><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: 100%; margin-left: calc(0%);\" width=\"174\"><thead><tr><th style=\"width: 17.4361%;\">Ticket Number</th><th style=\"width: 82.5639%;\">Summary</th></tr></thead><tbody><tr><td height=\"21\" style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; height: 16pt; width: 17.4361%;\" width=\"50%\">TEST-1</td><td style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; width: 82.5639%;\" width=\"50%\">Test 1 Summary</td></tr><tr><td height=\"21\" style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; height: 16pt; width: 17.4361%;\">TEST-2<br></td><td style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; width: 82.5639%;\">Test 2 Summary<br></td></tr><tr><td height=\"21\" style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; height: 16pt; width: 17.4361%;\">TEST-3<br></td><td style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; width: 82.5639%;\">Test 3 Summary<br></td></tr></tbody></table><p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong><span style=\"font-size: 28px;\"><img src=\"https://arn-resources.upraise.io/93c09ad4-8e4b-398f-9795-62f5ea84ea53/10069/47796/images/arn_file_2022-01-26-19-17-43-144.png\" alt=\"\" width=\"78\" height=\"12\" class=\"fr-fic fr-dii\"></span></strong></span></p><p><span style=\"font-family: arial, helvetica, sans-serif; font-size: 26px;\"><strong>Radiology</strong></span></p><p>&nbsp;</p><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: 100%;\" width=\"174\"><thead><tr><th style=\"width: 16.9972%;\">Ticket Number</th><th style=\"width: 83.0028%;\">Summary</th></tr></thead><tbody><tr><td height=\"21\" style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; height: 16pt; width: 16.9972%;\" width=\"50%\">TEST-4<br></td><td style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; width: 83.0028%;\" width=\"50%\">Test 4 Summary<br></td></tr><tr><td height=\"21\" style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; height: 16pt; width: 16.9972%;\">TEST-5<br></td><td style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; width: 83.0028%;\">Test 5 Summary<br></td></tr><tr><td height=\"21\" style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; height: 16pt; width: 16.9972%;\">TEST-6<br></td><td style=\"color: black; font-size: 16px; font-weight: 400; font-style: normal; text-decoration: none; vertical-align: bottom; width: 83.0028%;\">Test 6 Summary<br></td></tr></tbody></table><p><br></p>"
            }
        },
        "auto_save": false,
        "redirect_options": {
            "new_tab": false,
            "redirect_url": "https://"
        },
        "api_data": null,
        "thumbnail": {
            "url": ""
        },
        "banner": {
            "url": ""
        },
        "meta_data": null,
        "view_count": null,
        "quality_views": null,
        "index": 1,
        "current_version_number": "1.00",
        "date_created": "06/22/2023 2:15 pm EDT",
        "date_modified": "06/28/2023 1:38 am EDT",
        "date_published": false,
        "date_deleted": null,
        "date_archived": null,
        "date_last_viewed": null,
        "callout_created": "06/22/2023 2:15 pm EDT",
        "scheduled_publish_date": null,
        "scheduled_archive_date": null,
        "callout_expire": 1688615940,
        "reader_roles": null,
        "inherited_roles": null,
        "related_articles": [
            ""
        ],
        "user_teams": null,
        "tags": false,
        "parents": [
            "647796ad9f64a236df45c61c",
            "64948f9386fce851eb6f05a4"
        ],
        "snippets": null,
        "files": null,
        "topic_articles": null,
        "ready_versions": null,
        "redirect_link": [
            "test-release-notes"
        ],
        "search_phrases": false,
        "application_screens": [
            ""
        ],
        "languages": null,
        "template_article": false,
        "topic_article": false,
        "external_redirect": false,
        "callout_video": null,
        "prevent_searching": "",
        "hide_from_toc": false,
        "hide_from_page": false,
        "hide_from_widgets": false,
        "remove_pdf": "",
        "remove_feedback": false,
        "remove_comments": false,
        "visibility": "public",
        "callout": "none",
        "status": "draft"
    }
}

I've been able to pull the format of the article and the format of the tickets and fields that I'd like to combine.

I've spent some time putting the Jira response JSON into a pandas dataframe, but I think that was a bit misled.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Maybe [this](https://stackoverflow.com/questions/31011179/converting-json-to-html-table-in-python) helps you? – Peter234 Jun 28 '23 at 05:56
  • 1
    there are either some confusing or wrong phrases. You say an "HTML output should look like this" while it is not followed by HTML but an resolve in the form of a JSON. THe necessary information I miss is, how the rendered output is supposed to look like. – tacoshy Jun 28 '23 at 05:56

1 Answers1

1

I understand you will need HTML as a string in your python code. This is usually done with a HTML rendering engine. You can start at https://wiki.python.org/moin/Templating

Your example looks simple enough to be solved with the standard string.Template that is mentioned in the templating article. But the important part is, that you still need someone who will build that HTML table template for you.

There are UI component libraries available, but I am not aware of any of them simple enough for your application. They are designed to build web applications. I doubt that you will find one that just creates a nice HTML table from a python dict or array.

Jens Dibbern
  • 1,434
  • 2
  • 13
  • 20