Skip to content

Commit 08cefb4

Browse files
authored
Add version warning extension (dotnet#1523)
1 parent 35072bd commit 08cefb4

29 files changed

+117
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,4 @@ FakesAssemblies/
200200
project.lock.json
201201
**/sample/**/wwwroot/lib/
202202
**/samples/**/wwwroot/lib/
203+
__pycache__/

aspnet/client-side/angular.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Using Angular for Single Page Applications (SPAs)
24
=================================================
35

aspnet/client-side/bundling-and-minification.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc2
2+
13
Bundling and Minification
24
=========================
35

aspnet/conf.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@
3030
# Add any Sphinx extension module names here, as strings. They can be
3131
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3232
# ones.
33+
sys.path.append(os.path.abspath('ext'))
34+
3335
extensions = [
3436
'sphinx.ext.intersphinx',
35-
'sphinxcontrib.dotnetdomain']
37+
'sphinxcontrib.dotnetdomain',
38+
'versionwarning']
3639

3740
# Add any paths that contain templates here, relative to this directory.
3841
templates_path = ['_templates', '../common/_templates']
@@ -56,7 +59,7 @@
5659
# built documents.
5760
#
5861
# The short X.Y version.
59-
# version = '0.0.1'
62+
version = '1.0.0'
6063
# The full version, including alpha/beta/rc tags.
6164
# release = '0.0.1'
6265

@@ -374,3 +377,4 @@ def setup(app):
374377
'api': ('http://docs.asp.net/projects/api/en/latest', '../common/api.inv')
375378
}
376379

380+
versionwarning_console = False

aspnet/ext/versionwarning.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Add the ability to specify the version for a specific page.
4+
5+
This allows you to put metadata at the top of your document::
6+
7+
:version: 2.3
8+
9+
This version should be the version of the project that this page or API targets.
10+
11+
If you configure ``versionwarning_node`` to True (default),
12+
then it will generate an in-page warning for out of date versions.
13+
14+
If you configure ``versionwarning_console`` to True (default),
15+
then it will output a warning on the console.
16+
"""
17+
18+
19+
from collections import defaultdict
20+
21+
from sphinx.util.console import red, bold
22+
from docutils import nodes
23+
24+
25+
def process_meta(app, doctree, fromdocname):
26+
env = app.builder.env
27+
env.page_to_version = defaultdict(set)
28+
env.version_to_page = defaultdict(set)
29+
30+
# index metadata
31+
for pagename, metadata in iter(env.metadata.items()):
32+
if 'version' in metadata:
33+
version = metadata['version']
34+
env.page_to_version[pagename] = version
35+
env.version_to_page[version].add(pagename)
36+
37+
if fromdocname == pagename:
38+
39+
# Alert on outdated version
40+
current_version = env.config['version']
41+
if version != current_version:
42+
text = 'This page documents version {old} and has not yet been updated for version {new}'.format(
43+
old=version,
44+
new=current_version,
45+
)
46+
47+
if app.config['versionwarning_node']:
48+
prose = nodes.paragraph(text, text)
49+
warning = nodes.warning(prose, prose)
50+
doctree.insert(0, warning)
51+
if app.config['versionwarning_console']:
52+
app.warn(bold('[Version Warning: %s] ' % pagename) + red(text))
53+
54+
55+
def setup(app):
56+
app.connect('doctree-resolved', process_meta)
57+
app.add_config_value('versionwarning_node', True, 'html')
58+
app.add_config_value('versionwarning_console', True, 'html')

aspnet/fundamentals/app-state.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Managing Application State
24
==========================
35

aspnet/fundamentals/dependency-injection.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc2
2+
13
.. _fundamentals-dependency-injection:
24

35
Dependency Injection

aspnet/fundamentals/environments.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Working with Multiple Environments
24
==================================
35

aspnet/fundamentals/error-handling.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Error Handling
24
==============
35

aspnet/fundamentals/owin.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
OWIN
24
====
35

aspnet/fundamentals/routing.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc2
2+
13
Routing
24
=======
35
By `Steve Smith`_

aspnet/fundamentals/servers.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Servers
24
=======
35

aspnet/migration/http-modules.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Migrating HTTP Modules to Middleware
24
====================================
35

aspnet/migration/http-modules/sample/Asp.Net5/src/Asp.Net5/project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
1414
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
1515
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
16-
"Microsoft.AspNetCore.Http": "1.0.0-rc2-16272",
16+
"Microsoft.AspNet.Http": "1.0.0-rc1-final",
1717
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
1818
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
1919
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",

aspnet/migration/mvc.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc2
2+
13
Migrating From ASP.NET MVC to ASP.NET Core MVC
24
================================================
35

aspnet/migration/webapi.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Migrating from ASP.NET Web API
24
==============================
35

aspnet/mvc/controllers/dependency-injection.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
.. _dependency-injection-controllers:
24

35
Dependency Injection and Controllers

aspnet/mvc/controllers/testing.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Testing Controller Logic
24
========================
35
By `Steve Smith`_

aspnet/mvc/views/partial.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc2
2+
13
Partial Views
24
=============
35

aspnet/mvc/views/view-components.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
View Components
24
================
35

aspnet/mvc/views/working-with-forms.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Working with Forms
24
====================
35

aspnet/performance/caching/distributed.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Working with a Distributed Cache
24
================================
35

aspnet/performance/caching/memory.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc2
2+
13
In Memory Caching
24
=================
35

aspnet/performance/caching/response.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Response Caching
24
================
35

aspnet/security/authentication/2fa.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-beta8
2+
13
.. _security-authentication-2fa:
24

35
Two-factor authentication with SMS

aspnet/security/authentication/accconfirm.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-beta7
2+
13
.. _security-authentication-account-confirmation:
24

35
Account Confirmation and Password Recovery

aspnet/security/cors.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Enabling Cross-Origin Requests (CORS)
1+
:version: 1.0.0-rc1
2+
3+
Enabling Cross-Origin Requests (CORS)
24
=====================================
35

46
By `Mike Wasson`_

aspnet/testing/integration-testing.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc1
2+
13
Integration Testing
24
===================
35

aspnet/testing/unit-testing.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:version: 1.0.0-rc2
2+
13
Unit Testing
24
============
35

0 commit comments

Comments
 (0)