Skip to content
Snippets Groups Projects
Commit 948a55a0 authored by Antti Soininen's avatar Antti Soininen
Browse files

Fix page linking and small errors in dev-docs.

parent 8b8d5f7c
No related branches found
No related tags found
No related merge requests found
Showing
with 93 additions and 70 deletions
......@@ -372,7 +372,7 @@ The consequences are as follows:
It should not be logged, written as output, or used for branching execution paths since it is meaningless.
If the total number of spectra in a workspace is required it can be accessed via ``MatrixWorkspace::indexInfo()::globalSize()``.
- User input providing indices or spectrum numbers in one way or another must be translated into local indices by ``IndexInfo``.
The most common cases are a workspace property that also accepts indices, see `IndexProperty <../concepts/IndexProperty.html>`__.
The most common cases are a workspace property that also accepts indices, see :ref:`IndexProperty <IndexProperty>`.
- The distinction between local and global indices must not be exposed to the user.
In particular, the 'global' prefix should be omitted, i.e., for the user interface we keep referring to 'workspace index', even though it is internally not what used to be the workspace index but rather a global index.
Indices provided by a user may never be interpreted as local indices, since a local index has no fixed meaning.
......
......@@ -5,7 +5,7 @@ Getting Started with PyCharm
PyCharm can be installed from `here <https://jetbrains.com/pycharm/download/>`_.
This tutorial assumes you are familiar with the process of building Mantid (with separate source and build directories inside a root directory), and that you have built a working version. If you are unclear about this see `here <GettingStarted.html>`__
This tutorial assumes you are familiar with the process of building Mantid (with separate source and build directories inside a root directory), and that you have built a working version. If you are unclear about this see :ref:`here <GettingStarted>`.
.. contents::
:local:
......
.. _AddButton:
===============
Adding a Button
===============
......@@ -10,7 +12,7 @@ The View
The below code creates a QWidget containing a single button. When the
button is pressed it will print a message to the terminal screen. It
should be noted that in practice this should be avoided and will be
discussed in `this section <ReceivingSignalFromView.html>`_.
discussed in :ref:`this section <ReceivingSignalFromView>`.
First we need to import the relevant packages, this includes PyQt.
......@@ -42,10 +44,10 @@ Next we create a layout and add a button to it
# connect button to signal
self.button.clicked.connect(self.btn_click)
# add button to layout
grid.addWidget(self.button)
# set the layout for the view widget
self.setLayout(grid)
# add button to layout
grid.addWidget(self.button)
# set the layout for the view widget
self.setLayout(grid)
The above connect statement means that when the button is pressed, the
function ``btn_click`` is called:
......@@ -88,9 +90,9 @@ all been saved in ``view.py``, the ``main.py`` will contain:
def qapp():
if QtGui.QApplication.instance():
_app = QtGui.QApplication.instance()
else:
else:
_app = QtGui.QApplication(sys.argv)
return _app
return _app
app = qapp()
window = demo()
......
.. _AddComboBox:
==============
Add a ComboBox
==============
......
......@@ -18,6 +18,6 @@ edit (useful for tables).
Care should be taken before using a line edit as it can give a user
too much freedom. If you know that the input is an integer then a
`spin box <AddSpinBox.html>`_ is better. If there is a finite list of
possible options then a `combo box <AddComboBox.html>`_ would be a
:ref:`spin box <AddSpinBox>` is better. If there is a finite list of
possible options then a :ref:`combo box <AddComboBox>` would be a
better choice.
.. _AddSpinBox:
==============
Add a Spin Box
==============
......
......@@ -146,7 +146,7 @@ Plot Presenter
PlotView
########
Unchanged from `Matplotlib and MVP <Matplotlib.html>`_.
Unchanged from :ref:`Matplotlib and MVP <Matplotlib>`.
Presenter
#########
......@@ -171,9 +171,9 @@ Presenter
View
####
Unchanged from `Model Exercise Solution <ModelExerciseSolution.html>`_.
Unchanged from :ref:`Model Exercise Solution <ModelExerciseSolution>`.
Model
#####
Unchanged from `Model Exercise Solution <ModelExerciseSolution.html>`_.
Unchanged from :ref:`Model Exercise Solution <ModelExerciseSolution>`.
.. _Matplotlib:
==================
Matplotlib and MVP
==================
......
......@@ -8,4 +8,4 @@ mocked and the return values should be present only when necessary (on
this occasion the values do not matter). The ``updatePlot`` function
should be tested to make sure that it calls the correct methods.
See `here <MockingExerciseSolution.html>`_ for the solution.
See :ref:`here <MockingExerciseSolution>` for the solution.
.. _MockingExerciseSolution:
=========================
Mocking Exercise Solution
=========================
......
......@@ -15,4 +15,4 @@ input values
3. In the initialisation of the Presenter get the allowed colours from
the Model and pass them to the View
See `here <ModelExerciseSolution.html>`_ for the solution.
See :ref:`here <ModelExerciseSolution>` for the solution.
.. _ModelExerciseSolution:
=======================
Model Exercise Solution
=======================
......
.. _MultipleViews:
==============
Multiple Views
==============
......
......@@ -15,4 +15,4 @@ is pressed the following should be output:
The ``main`` module will also need updating to handle these changes.
See `here <PresenterExerciseSolution.html>`_ for the solution.
See :ref:`here <PresenterExerciseSolution>` for the solution.
.. _PresenterExerciseSolution:
===========================
Presenter Exercise Solution
===========================
......@@ -16,7 +18,7 @@ View
plotSignal = QtCore.pyqtSignal()
def __init__(self, parent=None):
def __init__(self, parent=None):
super(view, self).__init__(parent)
grid = QtGui.QVBoxLayout(self)
......@@ -52,22 +54,22 @@ View
self.plot.clicked.connect(self.buttonPressed)
def getColour(self):
def getColour(self):
return self.colours.currentText()
def getGridLines(self):
def getGridLines(self):
return self.grid_lines.checkState() == QtCore.Qt.Checked
def getFreq(self):
def getFreq(self):
return float(self.freq.text())
def getPhase(self):
def getPhase(self):
return float(self.phi.text())
def buttonPressed(self):
def buttonPressed(self):
self.plotSignal.emit()
def setTableRow(self, name, row):
def setTableRow(self, name, row):
text = QtGui.QTableWidgetItem(name)
text.setFlags(QtCore.Qt.ItemIsEnabled)
col = 0
......@@ -93,18 +95,18 @@ Presenter
class Presenter(object):
# pass the view and model into the presenter
def __init__(self, view):
def __init__(self, view):
self.view = view
self.view.plotSignal.connect(self.updatePlot)
self.view.plotSignal.connect(self.updatePlot)
# handle signals
def updatePlot(self):
# handle signals
def updatePlot(self):
print("The table settings are:")
print(" colour : " + str(self.view.getColour()))
print(" Grid lines : " + str(self.view.getGridLines()))
print(" Frequency : " + str(self.view.getFreq()))
print(" Phase : " + str(self.view.getPhase()))
print(" colour : " + str(self.view.getColour()))
print(" Grid lines : " + str(self.view.getGridLines()))
print(" Frequency : " + str(self.view.getFreq()))
print(" Phase : " + str(self.view.getPhase()))
Main module
###########
......@@ -136,12 +138,12 @@ Main module
self.setCentralWidget(my_view)
self.setWindowTitle("view tutorial")
def qapp():
def qapp():
if QtGui.QApplication.instance():
_app = QtGui.QApplication.instance()
else:
_app = QtGui.QApplication(sys.argv)
return _app
else:
_app = QtGui.QApplication(sys.argv)
return _app
app = qapp()
window = demo()
......
.. _ReceivingSignalFromView:
================================
Receiving a signal from the view
================================
In the `Add Button <AddButton.html>`_ section we had the response to a button press
In the :ref:`Add Button <AddButton>` section we had the response to a button press
within the View. In practice this is not a good implementation. If the
response was more complicated then it would be difficult to maintain
the View as it would become extremely long. Furthermore creating the
......@@ -23,7 +25,7 @@ pressed. First we will start with the View:
doSomethingSignal = QtCore.pyqtSignal()
def __init__(self, parent=None):
def __init__(self, parent=None):
super(view, self).__init__(parent)
self.button = QtGui.QPushButton('Hi', self)
......@@ -44,10 +46,10 @@ pressed. First we will start with the View:
# set the layout for the view widget
self.setLayout(grid)
#send signals
def btn_click(self):
#send signals
def btn_click(self):
print ("hellow from view")
self.doSomethingSignal.emit()
self.doSomethingSignal.emit()
The above code has two new additions. The first is the creation of a
custom signal on line eight. It is also possible to pass objects with
......@@ -67,13 +69,13 @@ custom signal from the View to its own function (``handleButton``).
class Presenter(object):
# pass the view and model into the presenter
def __init__(self, view):
def __init__(self, view):
self.view = view
self.view.doSomethingSignal.connect(self.handleButton)
self.view.doSomethingSignal.connect(self.handleButton)
# handle signals
def handleButton(self):
# handle signals
def handleButton(self):
print("hello world, from the presenter")
The main is now:
......@@ -105,12 +107,12 @@ The main is now:
self.setCentralWidget(my_view)
self.setWindowTitle("view tutorial")
def qapp():
def qapp():
if QtGui.QApplication.instance():
_app = QtGui.QApplication.instance()
else:
_app = QtGui.QApplication(sys.argv)
return _app
else:
_app = QtGui.QApplication(sys.argv)
return _app
app = qapp()
......
......@@ -17,7 +17,7 @@ plot. The table should include options for:
The previous sections are not an exhaustive list of possible widgets.
The pages `Matplotlib and MVP <Matplotlib.html>`_ and `MultipleView
<MultipleViews.html>`_ will be useful for the exercise.
The pages :ref:`Matplotlib and MVP <Matplotlib>` and :ref:`MultipleView
<MultipleViews>` will be useful for the exercise.
The solution can be found `here <ViewExercise1Solution.html>`_.
The solution can be found :ref:`here <ViewExercise1Solution>`.
.. _ViewExercise1Solution:
========================
View Exercise 1 Solution
========================
......@@ -30,12 +32,12 @@ main.py
self.setCentralWidget(my_view)
self.setWindowTitle("view tutorial")
def qapp():
def qapp():
if QtGui.QApplication.instance():
_app = QtGui.QApplication.instance()
else:
_app = QtGui.QApplication(sys.argv)
return _app
else:
_app = QtGui.QApplication(sys.argv)
return _app
app = qapp()
window = demo()
......
......@@ -10,7 +10,7 @@ Algorithm Documentation
Summary
=======
This page deals with the specifics of how to document an algorithm. For a more general guide to the Mantid documentation system see `Documentation Guide For Devs <DocumentationGuideForDevs.html>`__.
This page deals with the specifics of how to document an algorithm. For a more general guide to the Mantid documentation system see :ref:`Documentation Guide For Devs <DocumentationGuideForDevs>`.
How to Document an Algorithm
============================
......@@ -18,7 +18,7 @@ How to Document an Algorithm
Algorithm documentation is stored in two places.
* The code (.cpp / .h / .py) files: For strings that are needed in the GUI for tooltips etc.
* The .rst file: For all other documentation, including the algorithm description and `usage examples <AlgorithmUsageExamples.html>`__.
* The .rst file: For all other documentation, including the algorithm description and :ref:`usage examples <AlgorithmUsageExamples>`.
The Code Files
--------------
......@@ -69,7 +69,7 @@ For example:
Workflow algorithms
===================
There should be a flow chart for workflow algorithms. See `here <FlowchartCreation.html>`__ on how to make one.
There should be a flow chart for workflow algorithms. See :ref:`here <FlowchartCreation>` on how to make one.
Algorithm Directives
====================
......@@ -84,7 +84,7 @@ As the **Description** and **Usage** of an algorithm *cannot* be obtained automa
.. summary::
.. alias::
.. relatedalgorithms::
.. properties::
......@@ -120,13 +120,16 @@ As the **Description** and **Usage** of an algorithm *cannot* be obtained automa
return "Rebins data with new X bin boundaries. For EventWorkspaces, you can very quickly rebin in-place by keeping the same output name and PreserveEvents=true.";
}
``.. alias::``
This directive obtains aliases from the required ``alias`` method in the algorithm, for example, the following method is used in Rebin:
``.. relatedalgorithms::``
This directive obtains a list of related algorithm from the ``seeAlso`` method in the algorithm, for example, the following method is used in Rebin:
.. code-block:: c++
/// Algorithm's aliases
const std::string alias() const override { return "rebin"; }
/// Algorithm's seeAlso
const std::vector<std::string> seeAlso() const override {
return {"RebinToWorkspace", "Rebin2D", "Rebunch",
"Regroup", "RebinByPulseTimes", "RebinByTimeAtSample"};
}
``.. properties::``
As mentioned above, it is *critical* that you include a description for the properties of your algorithm. This directive obtains all of the algorithm's properties (set inside the algorithm's ``init`` method) and outputs in a table format.
......@@ -147,7 +150,7 @@ It is possible to add additional categories by passing the directive arguments,
.. categories:: Algorithms, Transforms, Rebin, Example
``..sourcelink ::``
``.. sourcelink::``
This directive adds links to the algorithms source code.
Description
......@@ -175,7 +178,7 @@ where the first part outside the angle brackets defines the link text and the pa
Usage
=====
This section *must* be manually entered. The usage is a 'code' example of the algorithm in use. The `testcode` directive must be used to verify the usage code you entered works correctly. See `here <AlgorithmUsageExamples>`__ for more information on how to write usage examples.
This section *must* be manually entered. The usage is a 'code' example of the algorithm in use. The ``.. testcode::`` directive must be used to verify the usage code you entered works correctly. See :ref:`here <AlgorithmUsageExamples>` for more information on how to write usage examples.
Building the Documentation
==========================
......
......@@ -18,7 +18,7 @@ From a user's point of view, the main purposes of usage examples are:
* Understanding the algorithm
* Showing hints/comments etc. that help understand Mantid Python scripting in general
The usage examples are written in `reStructuredText <http://docutils.sourceforge.net/rst.html>`__, which can be converted to HTML and the code in the usage examples can be tested. The image below demonstrates an example of converting reStructuredText to HTML.
The usage examples are written in `reStructuredText <http://docutils.sourceforge.net/rst.html>`__, which can be converted to HTML and the code in the usage examples can be tested.
Guide
=====
......@@ -75,7 +75,7 @@ What is worth keeping in mind is:
* Use comments.
* Use Python ``print`` to output results, which, where possible, helps to understand the algorithm.
A Jenkins job tests that the usage examples are not broken, i.e. that they continue to provide a working demonstration against the current build. It is vital to stress that the purpose of usage testing is *not to replace unit testing* (or system testing). The purpose of usage testing (better described as demonstration examples), is to provide some happy-path examples, which, where this is possible, can assist the user understanding of the Python code. This is very different from the purposes of testing in general, see `here <UnitTestGoodPractice.html>`__.
A Jenkins job tests that the usage examples are not broken, i.e. that they continue to provide a working demonstration against the current build. It is vital to stress that the purpose of usage testing is *not to replace unit testing* (or system testing). The purpose of usage testing (better described as demonstration examples), is to provide some happy-path examples, which, where this is possible, can assist the user understanding of the Python code. This is very different from the purposes of testing in general, see :ref:`here <UnitTestGoodPractice>`.
Additional benefits of usage examples:
......@@ -181,7 +181,7 @@ For a more simple use of CreateSampleWorkspace see example below (note if no arg
When needing to load a data file
--------------------------------
Instructions to add a new data file to the repository are available `here <DataFilesForTesting.html>`__. Files from the repository will be bundled up into a .zip file, and this .zip made available for download from the Mantid download page.
Instructions to add a new data file to the repository are available :ref:`here <DataFilesForTesting>`. Files from the repository will be bundled up into a .zip file, and this .zip made available for download from the Mantid download page.
If you use files you must add the line
......@@ -221,4 +221,4 @@ as shown in the example below. This will generate a note to the user explaining
Running the Tests
=================
See `here <DocumentationGuideForDevs.html>`__ for how to run and test the usage examples locally.
See :ref:`here <DocumentationGuideForDevs>` for how to run and test the usage examples locally.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment