Skip to content

Commit

Permalink
flattening package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
marzer committed Jul 28, 2023
1 parent 4d11426 commit e6eaf84
Show file tree
Hide file tree
Showing 198 changed files with 164 additions and 160 deletions.
33 changes: 15 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,26 @@ readme = { file = [

[tool.setuptools.packages.find]
where = ["src"]
# namespaces = true
include = ["poxy*"]

# [tool.setuptools.package-data]
# "*" = ['*.txt', '*.hpp', '.clang-format']

[tool.setuptools.exclude-package-data]
[tool.setuptools.package-data]
"*" = [
'meson.build',
'.git*',
'.istanbul.yaml',
'*.css',
'*.woff',
'*.woff2',
'*.json',
'*.rst',
'*.pyc',
'data/m.css/artwork/*',
'data/m.css/doc/*',
'data/m.css/documentation/test/*',
'data/m.css/documentation/test_doxygen/*',
'data/m.css/documentation/test_python/*',
'data/m.css/documentation/templates/python/*',
'data/m.css/package/*',
'data/m.css/plugins/m/test/*',
'data/m.css/site/*',
'*.html',
'*.xml',
'*.png',
'*.js',
'*.svg',
'*.txt',
]

[tool.setuptools.exclude-package-data]
"*" = ['meson.build', '.git*', '.istanbul.yaml', '*.pyc']

[tool.black]
line-length = 120
target-version = ['py37']
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 12 additions & 12 deletions src/poxy/data/css/poxy.css → src/poxy/css/poxy.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
*/

/* base font */
@import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600');
@import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600");

/* vars for dark theme */
@import url('m-theme-dark.css');
@import url('poxy-theme-dark.css');
@import url("m-theme-dark.css");
@import url("poxy-theme-dark.css");

/* vars for light theme */
@import url('m-theme-light.css');
@import url('poxy-theme-light.css');
@import url("m-theme-light.css");
@import url("poxy-theme-light.css");

/* m.css */
@import url('../m.css/css/m-grid.css');
@import url('../m.css/css/m-components.css');
@import url('m-special.css');
@import url('../m.css/css/m-layout.css');
@import url('poxy-pygments.css');
@import url('../m.css/css/m-documentation.css');
@import url("../mcss/css/m-grid.css");
@import url("../mcss/css/m-components.css");
@import url("m-special.css");
@import url("../mcss/css/m-layout.css");
@import url("poxy-pygments.css");
@import url("../mcss/css/m-documentation.css");

/* poxy overrides */
@import url('poxy-overrides.css');
@import url("poxy-overrides.css");
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ calc(var(--special-luminosity) * 1.4)
--detail-section-background-color: rgba(255, 255, 255, 0.3);
--sponsor-color: #f8c8dc;
}
/*==== ../m.css/css/m-grid.css =======================================================================================*/
/*==== ../mcss/css/m-grid.css ========================================================================================*/
*, ::before, ::after { box-sizing: border-box; }
body { margin: 0; }
.m-container { width: 100%; margin: auto; padding-left: 1rem; padding-right: 1rem; }
Expand Down Expand Up @@ -882,7 +882,7 @@ body { margin: 0; }
.m-show-l { display: block; }
.m-col-l-none { width: auto; float: none; }
}
/*==== ../m.css/css/m-components.css =================================================================================*/
/*==== ../mcss/css/m-components.css ==================================================================================*/
html { font-size: var(--font-size); background-color: var(--background-color); }
body { font-family: var(--font); font-size: 1rem; line-height: var(--line-height); color: var(--color); }
h1, h2, h3, h4, h5, h6 { margin-top: 0; font-weight: var(--heading-font-weight); }
Expand Down Expand Up @@ -1936,7 +1936,7 @@ div.m-plot svg .m-bar.m-special,
.m-graph g.m-node.m-special polyline,
.m-graph g.m-cluster.m-special polygon { stroke: var(--special-color); }
.m-container-inflatable section:target .m-note.m-info { border-color: var(--info-color); }
/*==== ../m.css/css/m-layout.css =====================================================================================*/
/*==== ../mcss/css/m-layout.css ======================================================================================*/
body > header > nav { width: 100%; background-color: var(--header-background-color); min-height: 3rem; }
body > header > nav.m-navbar-landing,
body > header > nav.m-navbar-cover { background-color: transparent; position: relative; }
Expand Down Expand Up @@ -2462,7 +2462,7 @@ border-left-width: 0.125rem;
.m-console .go { color: var(--console-color); }
.m-console .gp { color: #16a085; font-weight: bold }
.m-console .w { color: var(--console-color); }
/*==== ../m.css/css/m-documentation.css ==============================================================================*/
/*==== ../mcss/css/m-documentation.css ===============================================================================*/
a.m-doc, a.m-doc-self, a.m-doc-external,
ul.m-doc li.m-doc-expansible > a:first-child, ul.m-doc li.m-doc-collapsible > a:first-child,
.m-code.m-inverted.m-doc-include > a { text-decoration: none; }
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 8 additions & 5 deletions src/poxy/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@
TESTS = Path(REPOSITORY, r'tests')
"""The root directory of the repository's tests."""

DATA = Path(PACKAGE, r'data')
"""The root directory of all package data."""
IMG = Path(PACKAGE, r'img')
"""The img directory."""

CSS = Path(DATA, r'css')
CSS = Path(PACKAGE, r'css')
"""The css directory."""

MCSS = Path(DATA, r'm.css')
JS = Path(PACKAGE, r'js')
"""The js directory."""

MCSS = Path(PACKAGE, r'mcss')
"""The root directory of the bundled m.css build."""

GENERATED = Path(DATA, r'generated')
GENERATED = Path(PACKAGE, r'generated')
"""The root directory of all auto-generated package data."""

FONTS = Path(GENERATED, r'fonts')
Expand Down
45 changes: 24 additions & 21 deletions src/poxy/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,11 +1154,12 @@ def __init__(
self.now = datetime.datetime.utcnow().replace(microsecond=0, tzinfo=datetime.timezone.utc)

self.verbose_value(r'dirs.PACKAGE', paths.PACKAGE)
self.verbose_value(r'dirs.DATA', paths.DATA)
self.verbose_value(r'dirs.MCSS', paths.MCSS)
self.verbose_value(r'dirs.CSS', paths.CSS)
self.verbose_value(r'dirs.GENERATED', paths.GENERATED)
self.verbose_value(r'dirs.FONTS', paths.FONTS)
self.verbose_value(r'dirs.IMG', paths.IMG)
self.verbose_value(r'dirs.JS', paths.JS)
self.verbose_value(r'dirs.MCSS', paths.MCSS)
self.verbose_value(r'dirs.TEMP', paths.TEMP)
self.verbose_value(r'doxygen.path()', doxygen.path())

Expand All @@ -1171,7 +1172,7 @@ def __init__(
self.verbose_value(r'Context.output_dir', self.output_dir)
assert self.output_dir.is_absolute()
self.case_sensitive_paths = not (
Path(str(paths.DATA).upper()).exists() and Path(str(paths.DATA).lower()).exists()
Path(str(paths.PACKAGE).upper()).exists() and Path(str(paths.PACKAGE).lower()).exists()
)
self.verbose_value(r'Context.case_sensitive_paths', self.case_sensitive_paths)

Expand Down Expand Up @@ -1254,7 +1255,7 @@ def __init__(
assert self.mcss_conf_path.is_absolute()

# misc
self.cppref_tagfile = coerce_path(paths.DATA, r'cppreference-doxygen-web.tag.xml').resolve()
self.cppref_tagfile = coerce_path(paths.PACKAGE, r'cppreference-doxygen-web.tag.xml').resolve()
self.verbose_value(r'Context.cppref_tagfile', self.cppref_tagfile)
assert_existing_file(self.cppref_tagfile)
assert self.cppref_tagfile.is_absolute()
Expand All @@ -1266,15 +1267,21 @@ def __init__(
self.scripts = []
self.stylesheets = []

def add_internal_asset(p):
def add_internal_asset(p) -> str:
nonlocal extra_files
nonlocal self
if not self.copy_assets:
return
assert p is not None
p = coerce_path(p)
if not p.is_absolute():
p = Path(paths.DATA, p)
extra_files.append((p, rf'poxy/{p.name}'))
if self.copy_assets:
if not p.is_absolute():
for dir in (paths.FONTS, paths.GENERATED, paths.JS, paths.IMG):
new_p = dir / p
if new_p.exists():
p = new_p
break
assert_existing_file(p)
extra_files.append((p, rf'poxy/{p.name}'))
return rf'poxy/{p.name}'

config = dict()
if self.config_path.exists():
Expand Down Expand Up @@ -1317,12 +1324,11 @@ def add_internal_asset(p):
badge = re.sub(r'(?:[.]0+)+$', '', spdx.lower()) # trailing .0, .0.0 etc
badge = badge.strip(' \t-._:') # leading + trailing junk
badge = re.sub(r'[:;!@#$%^&*\\|/,.<>?`~\[\]{}()_+\-= \t]+', '_', badge) # internal junk
badge = Path(paths.DATA, rf'poxy-badge-license-{badge}.svg')
badge = Path(paths.IMG, rf'poxy-badge-license-{badge}.svg')
self.verbose(rf"Finding badge SVG for license '{spdx}'...")
if badge.exists():
self.verbose(rf'Badge file found at {badge}')
add_internal_asset(badge)
badges.append((spdx, rf'poxy/{badge.name}', uri))
badges.append((spdx, add_internal_asset(badge), uri))
self.verbose_value(r'Context.license', self.license)

# project repo access level
Expand Down Expand Up @@ -1402,8 +1408,7 @@ def add_internal_asset(p):
elif r'theme' in config:
self.theme = str(config[r'theme'])
if self.theme != r'custom':
add_internal_asset(Path(paths.DATA, r'generated', r'poxy.css'))
self.stylesheets.append(rf'poxy/poxy.css')
self.stylesheets.append(add_internal_asset(paths.GENERATED / r'poxy.css'))
self.verbose_value(r'Context.theme', self.theme)

# stylesheets (HTML_EXTRA_STYLESHEETS)
Expand All @@ -1421,14 +1426,12 @@ def add_internal_asset(p):

# jquery
if r'jquery' in config and config[r'jquery']:
jquery = enumerate_files(paths.DATA, any=r'jquery*.js')[0]
jquery = enumerate_files(paths.JS, any=r'jquery*.js')[0]
if jquery is not None:
add_internal_asset(jquery)
self.scripts.append(rf'poxy/{jquery.name}')
self.scripts.append(add_internal_asset(jquery))

# scripts
add_internal_asset(r'poxy.js')
self.scripts.append(r'poxy/poxy.js')
self.scripts.append(add_internal_asset(paths.JS / r'poxy.js'))
if r'scripts' in config:
for f in coerce_collection(config[r'scripts']):
file = f.strip()
Expand Down Expand Up @@ -1787,7 +1790,7 @@ def add_internal_asset(p):
extra_files.append(Path(file))

# add all the 'icon' svgs as internal assets so they can be used by users if they wish
for f in enumerate_files(paths.DATA, all='poxy-icon-*.svg', recursive=False):
for f in enumerate_files(paths.IMG, all='poxy-icon-*.svg', recursive=False):
add_internal_asset(f)

# finalize extra_files
Expand Down
11 changes: 7 additions & 4 deletions src/poxy/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,11 +1104,14 @@ def preprocess_mcss_config(context: Context):
if 1:
# stylesheets
for stylesheet in context.stylesheets:
assert stylesheet is not None
html_header += f'<link href="{stylesheet}" rel="stylesheet" referrerpolicy="no-referrer" />\n'
# scripts
for script in context.scripts:
assert script is not None
html_header += f'<script src="{script}"></script>\n'
if context.theme != r'custom':
assert context.theme is not None
html_header += f'<script>initialize_theme("{context.theme}");</script>\n'

# metadata
Expand Down Expand Up @@ -1221,7 +1224,7 @@ def add_meta_kvp(key_name, key, content):
if not context.repo:
bar[i] = None
continue
icon_path = Path(paths.DATA, context.repo.icon_filename)
icon_path = Path(paths.IMG, context.repo.icon_filename)
if icon_path.exists():
svg = SVG(icon_path, logger=context.verbose_logger, root_id=r'poxy-icon-repo')
bar[i] = (
Expand All @@ -1234,7 +1237,7 @@ def add_meta_kvp(key_name, key, content):
bar[i] = None
elif bar[i] == r'theme':
svg = SVG(
Path(paths.DATA, r'poxy-icon-theme.svg'),
Path(paths.IMG, r'poxy-icon-theme.svg'),
logger=context.verbose_logger,
root_id=r'poxy-theme-switch-img',
)
Expand All @@ -1246,7 +1249,7 @@ def add_meta_kvp(key_name, key, content):
)
elif bar[i] == r'twitter':
svg = SVG(
Path(paths.DATA, r'poxy-icon-twitter.svg'),
Path(paths.IMG, r'poxy-icon-twitter.svg'),
logger=context.verbose_logger,
root_id=r'poxy-icon-twitter',
)
Expand All @@ -1258,7 +1261,7 @@ def add_meta_kvp(key_name, key, content):
)
elif bar[i] == r'sponsor':
svg = SVG(
Path(paths.DATA, r'poxy-icon-sponsor.svg'),
Path(paths.IMG, r'poxy-icon-sponsor.svg'),
logger=context.verbose_logger,
root_id=r'poxy-icon-sponsor',
)
Expand Down
8 changes: 3 additions & 5 deletions tests/regenerate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ def regenerate_expected_outputs():
)
for path in files:
text = read_all_text_from_file(path)
text = text.replace(r'href="poxy/poxy.css"', r'href="../../../src/poxy/data/css/poxy.css"')
text = text.replace(r'src="poxy/poxy.js"', r'src="../../../src/poxy/data/poxy.js"')
text = text.replace(r'src="search-v2.js"', r'src="../../../src/poxy/data/m.css/documentation/search.js"')
text = text.replace(r'href="poxy/', r'href="../../../src/poxy/data/')
text = text.replace(r'src="poxy/', r'src="../../../src/poxy/data/')
text = text.replace(r'href="poxy/poxy.css"', r'href="../../../src/poxy/css/poxy.css"')
text = text.replace(r'src="poxy/poxy.js"', r'src="../../../src/poxy/js/poxy.js"')
text = text.replace(r'src="search-v2.js"', r'src="../../../src/poxy/mcss/documentation/search.js"')
text = re.sub(r'Poxy v[0-9]+[.][0-9]+[.][0-9]+', r'Poxy v0.0.0', text)
text = re.sub(r'version="\s*[0-9]+[.][0-9]+[.][0-9]+\s*"', r'version="0.0.0"', text)
text = re.sub(r'gitid="\s*[0-9a-fA-F]+\s*"', r'gitid="000000000000000000000000000000000000000"', text)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_empty_project/expected_html/annotated.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link href="favicon-dark.png" rel="icon" type="image/png"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<meta content="#22272e" name="theme-color"/>
<link href="../../../src/poxy/data/css/poxy.css" referrerpolicy="no-referrer" rel="stylesheet"/>
<script src="../../../src/poxy/data/poxy.js"></script>
<link href="../../../src/poxy/css/poxy.css" referrerpolicy="no-referrer" rel="stylesheet"/>
<script src="../../../src/poxy/js/poxy.js"></script>
<script>initialize_theme("dark");</script>
<meta content="telephone=no" name="format-detection"/>
<meta content="Poxy v0.0.0" name="generator"/>
Expand Down Expand Up @@ -100,7 +100,7 @@ <h1>Classes</h1>
</div>
</div>
</div>
<script src="../../../src/poxy/data/m.css/documentation/search.js"></script><script>install_mcss_search_shim();</script>
<script src="../../../src/poxy/mcss/documentation/search.js"></script><script>install_mcss_search_shim();</script>
<script async="async" src="searchdata-v2.js"></script>
<footer><nav>
<div class="m-container">
Expand Down
6 changes: 3 additions & 3 deletions tests/test_empty_project/expected_html/concepts.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link href="favicon-dark.png" rel="icon" type="image/png"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<meta content="#22272e" name="theme-color"/>
<link href="../../../src/poxy/data/css/poxy.css" referrerpolicy="no-referrer" rel="stylesheet"/>
<script src="../../../src/poxy/data/poxy.js"></script>
<link href="../../../src/poxy/css/poxy.css" referrerpolicy="no-referrer" rel="stylesheet"/>
<script src="../../../src/poxy/js/poxy.js"></script>
<script>initialize_theme("dark");</script>
<meta content="telephone=no" name="format-detection"/>
<meta content="Poxy v0.0.0" name="generator"/>
Expand Down Expand Up @@ -100,7 +100,7 @@ <h1>Concepts</h1>
</div>
</div>
</div>
<script src="../../../src/poxy/data/m.css/documentation/search.js"></script><script>install_mcss_search_shim();</script>
<script src="../../../src/poxy/mcss/documentation/search.js"></script><script>install_mcss_search_shim();</script>
<script async="async" src="searchdata-v2.js"></script>
<footer><nav>
<div class="m-container">
Expand Down
6 changes: 3 additions & 3 deletions tests/test_empty_project/expected_html/files.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link href="favicon-dark.png" rel="icon" type="image/png"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<meta content="#22272e" name="theme-color"/>
<link href="../../../src/poxy/data/css/poxy.css" referrerpolicy="no-referrer" rel="stylesheet"/>
<script src="../../../src/poxy/data/poxy.js"></script>
<link href="../../../src/poxy/css/poxy.css" referrerpolicy="no-referrer" rel="stylesheet"/>
<script src="../../../src/poxy/js/poxy.js"></script>
<script>initialize_theme("dark");</script>
<meta content="telephone=no" name="format-detection"/>
<meta content="Poxy v0.0.0" name="generator"/>
Expand Down Expand Up @@ -100,7 +100,7 @@ <h1>Files</h1>
</div>
</div>
</div>
<script src="../../../src/poxy/data/m.css/documentation/search.js"></script><script>install_mcss_search_shim();</script>
<script src="../../../src/poxy/mcss/documentation/search.js"></script><script>install_mcss_search_shim();</script>
<script async="async" src="searchdata-v2.js"></script>
<footer><nav>
<div class="m-container">
Expand Down
Loading

0 comments on commit e6eaf84

Please sign in to comment.