-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOCSP-8430: Improve role rendering (#154)
- Loading branch information
Showing
38 changed files
with
296 additions
and
460 deletions.
There are no files selected for viewing
Submodule docs-tools
updated
16 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,43 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import ComponentFactory from './ComponentFactory'; | ||
import Link from './Link'; | ||
|
||
// TODO: Properly render ref_role nodes with links and labels | ||
const RefRole = () => <span>RefRole</span>; | ||
const RefRole = ({ nodeData: { children, domain, fileid, name, target, url }, slug }) => { | ||
// Render intersphinx target links | ||
if (url) { | ||
return ( | ||
<Link to={url} className="reference external"> | ||
{children.map((node, i) => ( | ||
<ComponentFactory key={i} nodeData={node} /> | ||
))} | ||
</Link> | ||
); | ||
} | ||
|
||
// Render internal target links | ||
const link = fileid === slug ? `#${target}` : `${fileid}#${target}`; | ||
return ( | ||
<Link to={link} className="reference internal"> | ||
<span className={`${domain} ${domain}-ref`}> | ||
{children.map((node, i) => ( | ||
<ComponentFactory key={i} nodeData={node} /> | ||
))} | ||
</span> | ||
</Link> | ||
); | ||
}; | ||
|
||
RefRole.propTypes = { | ||
nodeData: PropTypes.shape({ | ||
children: PropTypes.arrayOf(PropTypes.node).isRequired, | ||
domain: PropTypes.string.isRequired, | ||
fileid: PropTypes.string, | ||
name: PropTypes.string.isRequired, | ||
target: PropTypes.string.isRequired, | ||
url: PropTypes.string, | ||
}).isRequired, | ||
slug: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default RefRole; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const Abbr = ({ | ||
nodeData: { | ||
children: [{ value }], | ||
}, | ||
}) => { | ||
if (!value) { | ||
return null; | ||
} | ||
|
||
// Abbreviations appear as "ABBR (Full Name Here)", so separate this into `abbr` and `expansion` | ||
let [abbr, expansion] = value.split('('); | ||
expansion = expansion.split(')')[0]; | ||
return <abbr title={expansion}>{abbr}</abbr>; | ||
}; | ||
|
||
Abbr.propTypes = { | ||
nodeData: PropTypes.shape({ | ||
children: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
value: PropTypes.string.isRequired, | ||
}) | ||
).isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
export default Abbr; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import ComponentFactory from '../ComponentFactory'; | ||
|
||
const RoleFile = ({ nodeData: { children } }) => ( | ||
<code className="file docutils literal"> | ||
<span className="pre"> | ||
{children.map((node, i) => ( | ||
<ComponentFactory key={i} nodeData={node} /> | ||
))} | ||
</span> | ||
</code> | ||
); | ||
|
||
RoleFile.propTypes = { | ||
nodeData: PropTypes.shape({ | ||
children: PropTypes.arrayOf(PropTypes.node).isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
export default RoleFile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.