wpilibsuite / sphinxext-opengraph

Sphinx extension to generate unique OpenGraph metadata
https://sphinxext-opengraph.readthedocs.io
Other
74 stars 27 forks source link

Tidy up whitespace #69

Closed hugovk closed 1 year ago

hugovk commented 1 year ago

Before

The og meta tags have no indent and are double spaced:

<!doctype html>
<html class="no-js">
  <head><meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1"/>
    <meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<meta property="og:title" content="sphinxext-opengraph" />

<meta property="og:type" content="website" />

<meta property="og:url" content="index.html" />

<meta property="og:description" content="Build Code style: black Sphinx extension to generate OpenGraph metadata (https://ogp.me/) Installation: python -m pip install sphinxext-opengraph Usage: Just add sphinxext.opengraph to your extensi..." />
  <link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" />

    <meta name="generator" content="sphinx-4.2.0, furo 2021.11.12.1"/>
        <title>sphinxext-opengraph 1.0 documentation</title>
      <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=cb850144ff767e23c5b2a31c47cdfe5847ae013d" />
    <link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?digest=0af69da206d614734f649b27d4cdc2dd6c31f41d" />

https://sphinxext-opengraph.readthedocs.io/en/latest/

After

Give them four-space indents and only a single newline:

<!doctype html>
<html class="no-js">
  <head><meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1"/>
    <meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
    <meta property="og:title" content="sphinxext-opengraph" />
    <meta property="og:type" content="website" />
    <meta property="og:url" content="index.html" />
    <meta property="og:description" content="Build Code style: black Sphinx extension to generate OpenGraph metadata (https://ogp.me/) Installation: python -m pip install sphinxext-opengraph Usage: Just add sphinxext.opengraph to your extensi..." />
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" />

    <meta name="generator" content="sphinx-4.2.0, furo 2021.11.12.1"/>
        <title>sphinxext-opengraph 1.0 documentation</title>
      <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=cb850144ff767e23c5b2a31c47cdfe5847ae013d" />
    <link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?digest=0af69da206d614734f649b27d4cdc2dd6c31f41d" />
TheTripleV commented 1 year ago

I agree that the double spacing should be fixed.

However, I don't think that the indent issue can be solved by whitespace padding. Isn't the correct indent depth based off of the theme template? So it will be wrong depending on the theme used?

hugovk commented 1 year ago

Yes, I guess so.

We should at least have a consistent indent, whether we use zero, two or four spaces.


Looks like the default Sphinx theme uses four spaces:

Furo uses four:

sphinx_rtd_theme uses two:

python-docs-theme extends the default Sphinx theme and uses four spaces for their single meta addition:

TheTripleV commented 1 year ago

Ah, that's where I noticed the discrepancy. The documentation this extension was created for uses sphinx_rtd_theme while this extension itself uses furo.

I think using zero would be best then, as it doesn't affect the output and makes the code easiest to read.

hugovk commented 1 year ago

Sounds good, updated with zero space indent:

<!doctype html>
<html class="no-js">
  <head><meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1"/>
    <meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta property="og:title" content="sphinxext-opengraph" />
<meta property="og:type" content="website" />
<meta property="og:url" content="index.html" />
<meta property="og:description" content="Build Code style: black Sphinx extension to generate OpenGraph metadata (https://ogp.me/) Installation: python -m pip install sphinxext-opengraph Usage: Just add sphinxext.opengraph to your extensi..." />
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" />

    <meta name="generator" content="sphinx-4.5.0, furo 2021.11.12.1"/>
        <title>sphinxext-opengraph 1.0 documentation</title>
      <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=cb850144ff767e23c5b2a31c47cdfe5847ae013d" />
    <link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?digest=0af69da206d614734f649b27d4cdc2dd6c31f41d" />